Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Position data not as expected on episode begin

Discussion in 'ML-Agents' started by stulleman, Oct 3, 2020.

  1. stulleman

    stulleman

    Joined:
    Jun 5, 2013
    Posts:
    44
    To make the example very basic, I have:

    Code (CSharp):
    1. public override void OnEpisodeBegin() {
    2.         rBody.angularVelocity = Vector3.zero;
    3.         rBody.velocity = Vector3.zero;
    4.  
    5.         transform.localPosition = new Vector3(0, 2.0f, 0);
    6.         transform.localRotation = Quaternion.identity;
    7.  
    8.         started = Time.time;
    9.         RequestDecision();
    10. }
    When I print the position in CollectObservations (Debug.Log(transform.localPosition); ) then the position is not as expected at (0.0, 2.0, 0.0) but randomly at (1.2, 3.2, 1.2), (5.1, 6.0, 5.1) or (0.0, 2.0, 0.0).

    Am I doing something wrong or is this a bug?

    EDIT:

    I realized that CollectObservations is called 2 times. When I call RequestDecision and when I call EndEpisode. Why is this? How can I prevent it?
     
    Last edited: Oct 3, 2020
  2. henrypeteet

    henrypeteet

    Unity Technologies

    Joined:
    Aug 19, 2020
    Posts:
    37
    Sorry that I don't currently understand your issue. EndEpisode will collect observations by design since commonly a large reward or punishment is added in the last step. Is there a reason you don't want it to? Are you calling EndEpisode at the beginning of your game?