Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

RigidBody.velocity different in Simulate(t)

Discussion in 'Physics' started by Crouching-Tuna, Jun 6, 2019.

  1. Crouching-Tuna

    Crouching-Tuna

    Joined:
    Apr 4, 2014
    Posts:
    82
    Hi all.

    So i've read the docs that FixedUpdate is independet from the time rate passed to Simulate.
    OnCollision is still called by the objects running Simulate, so i'm checking the values there.

    Basically here's what i do:
    Code (CSharp):
    1. void OnCollisionEnter()
    2. {
    3.                 Vector3 pushDir = new Vector3(myBody.velocity.x, 3f, myBody.velocity.z * 2f);
    4.                 Pushed(pushDir);
    5. }
    And then i also have a replay system, just playing back things that happened, in different speed.
    Like when someone scored a goal, they like to playback the moments to the goal

    So the replay system works just fine, the slow-mo too.
    Pushed is just a way to override the collision results, but that's not important.
    What's weird is the result of myBody.velocity is different on different slow-mo speeds.

    So...
    Is it possible that making Simulate slow-mo (using fraction of a constant Time.fixedDeltaTime) can detect the OnCollision earlier/later, diverging the physics story slightly differently?

    Cheers

    edit:
    Oh forgot to mention.
    The real object, in normal time speed, gives exactly the same velocity value in their OnCollision, as the replay object undergoing Simulate also with normal speed. So i'm sure that it can be accurate if not for the different time speed.
     
    Last edited: Jun 7, 2019