Search Unity

Behavior of physics different in full speed vs. single step

Discussion in 'Editor & General Support' started by jeffcraighead, Dec 25, 2006.

  1. jeffcraighead

    jeffcraighead

    Joined:
    Nov 15, 2006
    Posts:
    740
    Is there something I'm missing here. Whenever I use the single frame step in the editor the physics stuff behaves completely differently (more stable).
     
  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    In my experience, the physics engine performs more accurately the more processor power is available. You can't rely on it to do exactly the same thing every time given the same starting conditions.
     
  3. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    Are you sure you're applying forces / moving / whatever with the physic engine ONLY during FixedUpdate or from trigger forces?
     
  4. jeffcraighead

    jeffcraighead

    Joined:
    Nov 15, 2006
    Posts:
    740
    I am pretty sure I tried it both ways. I've got it behaving more or less how I want now using FixedUpdate for applying forces. What is the difference in how forces are applied in Update vs FixedUpdate? I assume the only difference is how often the loops run in which the forces are applied. i.e. Forces are applied more often in FixedUpdate vs Update.

    Thanks!
     
  5. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Update is run every frame. The period between Update's can vary greatly depending on framerate. As far as physics are concerned, when you use a function like AddForce, that function is applied over the duration of the frame - so slower framerates will mean that AddForce(1) will end up making the object go much faster than AddForce(1) on a frame when the framerate is fast. (AddForce takes a Vector3 and that might be reversed, but the point is, it's not reliable.)

    The physics engine is updated once at the same time that FixedUpdate is run, and the period between them is constant (I think 0.01 seconds is the default) - i.e. Time.fixedDeltaTime. So an AddForce in FixedUpdate will always apply the same amount of force (and be run the same amount of times per second)