No matter how long i set timestep, after clicking play mode, fixedUpdate() run immediately ?

No matter how long i set timestep, after clicking play mode, fixedUpdate() run immediately ? so fixedupdate called first time shouldn’t wait until the first fixed time interval finish?

i am a beginner, thx!

I think you should read this. You’ll learn a lot about what’s actually going on in FixedUpdate() (case-sensitive! make sure ‘F’ is capital).

The part of that info that pertains to your problem is that FixedUpdate() is always called just before Update(). Just after launch, you’ll always get one for the first frame. Whether or not FixedUpdate() is called (and how many times) just before the second frame will depend on the interval.

You should also read this carefully:

Includes a comprehensive graph describing the execution order of events and the particular conditions:
2662962--187800--upload_2016-6-3_21-16-26.png

@Hyblademin , thx, i learn more about FixedUpdate() and Update() relationship, but i still not find a answer.
@Edy, I understand FixedUpdate() execution order, while which is not my problem.

my problem is: Why after launch, FixedUpdate() called immediately. E.g, just add a cube, in Start() i set Time.fixedDeltaTime = 10.0f, rigidbody velocity = (0f, -1f, 0f), turn off Gravity, And then begin to debug. After Clicking PlayMode in UnityEditor, you vl find that, At the moment you enter PlayMode, RigidBody’s position became (0, -10, 0), in the other words, At the moment you enter, FixedUpdate() has been called first time, Not Wait 10 Seconds Later ! !!! But unless first time, later FixedUpdate() is noraml ! In my opinion, the first time FixedUpdate() called should wait until 10 seconds later in the case, Not after launch immediately !

public class Test : MonoBehaviour {

    private Rigidbody m_rb;

    void Awake(){
        m_rb = GetComponent<Rigidbody> ();
    }

    void Start(){
        m_rb.velocity = new Vector3 (0f, -1f, 0f);

        Time.fixedDeltaTime = 10f;
    }

    void FixedUpdate(){
        Debug.Log ( Time.realtimeSinceStartup );
    }
}

2663361--187840--capture1.PNG
2663361--187841--capture2.PNG

When FixedUpdate is executed the first time then all the current values are taken into account in order to calculate the new physics state. What happens at Internal Physics Update with your rigidbody is:

rigidbody.position = rigidbody.position + rigidbody.velocity * Time.fixedDeltaTime

So:

  • start position is 0
  • velocity is -1
  • fixedDeltaTime is 10

Then, the first calculation will result:

position = 0 + (-1) * 10 = -10

There’s nothing wrong there. fixedDeltaTime is an interval, not a delay. An internal physics update will be executed on entering Play mode using the actual values of the physics objects. So the calculations are just correct, and that’s the expected behavior.

As workaround, you might try setting the initial position to +10 at Start:

void Start(){
        m_rb.velocity = new Vector3 (0f, -1f, 0f);
        m_rb.position = new Vector3 (0f, 10f, 0f);

        Time.fixedDeltaTime = 10f;
    }

Then the position will be calculated to 0 at the first physics step, and it will take another 10 seconds to update to a new position.

@Edy , thanks for your explanation, i understand now. Unity’s behaviour isn’t in line with my expectations, i need learn more. Thanks Again!