Position data not as expected on episode begin

To make the example very basic, I have:

public override void OnEpisodeBegin() {
        rBody.angularVelocity = Vector3.zero;
        rBody.velocity = Vector3.zero;

        transform.localPosition = new Vector3(0, 2.0f, 0);
        transform.localRotation = Quaternion.identity;

        started = Time.time;

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?


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?

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?