Search Unity

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

Upgrade Unity and Havok Physics results in complete change in game physics

Discussion in 'Physics for ECS' started by zardini123, Aug 13, 2020.

  1. zardini123

    zardini123

    Joined:
    Jan 5, 2013
    Posts:
    68
    Today I upgraded my Unity version and all my packages to support the newest Unity Physics (0.4.1) and Havok Physics (0.3.1). Before this, I was on Unity Physics 0.3 and Havok 0.2.2. I use Havok as my physics engine.

    Once imports completed and API's were fixed, I see now the physics of my game is wild different from before the upgrade. All the physics package upgrades I've done to this point has not changed how the physics of my game behaved until today.

    The change I'm experiencing is what I think to be related to how the physics react to impulses. My game has heavy reliance on PhysicsWorldExtensions.ApplyImpulse and the related to apply forces to objects (I apply impulse from force via I = F * ∆t). Every property of my game that utilizes impulses now acts differently. I scurried over every changelog I can think of including both physics packages. I could not find any entry stating any change in physics behavior regarding impulses, velocities, or just general behavior.

    Does anybody knows of any changes to the physics packages that has resulted in this change? Did the folks at Havok change some things internally to the simulation that now responds to velocity/impulse interactions different from before? Did simply the ApplyImpulse function change?
     
  2. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    Does this mean you are working on the runtime simulation data rather than the Component data at the ECS level?PhysicsWorldExtensions.ApplyImpulse hasn't changed in a long time.
    Would the deltaTime have changed significantly instead? Would it be possible to get a small sample to test locally?
     
  3. zardini123

    zardini123

    Joined:
    Jan 5, 2013
    Posts:
    68
    No I'm interfacing with Havok purely from Component data. I am not modifying simulation behavior in any way.

    I heavily rely on the Havok feature "Body Tags for Contact Welding", but this doesn't seem related to my problems.

    I am forcing the entirety of SimulationSystemGroup to run every fixed update by moving the group to FixedUpdate player loop as stated here. The fixed tilmestep is still 0.02 (50 fps). Has there been any changes to simulation that would have incorrect updating due to this method?

    Just to clarify, the physics between before and after upgrading isn't so wild to the point that everything explodes. All the physics is close to what it used to be, but due to the bodies interaction from the impulses being different in a small degree, the entire game's gameplay is broken. In other words, my game is heavily based on physics, and due to this small physics change, my entire game is "broken."
     
  4. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Maybe some ordering of systems changed and you have logic where that would matter? System ordering has changed now and then, where you don't explicitly set order.

    Other then a change in velocity behavior some timing issue like that is my best guess.
     
  5. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    There have also been some runtime behavior changes that you may have relied on previously, like the fact that queries on RigidBody are now in world space. I suggest going through the changelog and checking all sections to make sure there is nothing you missed in there. Also, there's always an option that there is a bug, so it would be beneficial to see where are the differences coming from.

    We haven't really changed anything related to impulses, both in Unity and Havok physics. Also reply from @snacktime could be onto something, ordering is usually a good guess.
     
  6. zardini123

    zardini123

    Joined:
    Jan 5, 2013
    Posts:
    68
    What constitutes as a RigidBody query? I only query collision/contact data so I don't think thats it. Especially being that functionality went from local to world space, if my code used that, my physics would be more wild different the farther one gets from origin.

    Yeah I've been scanning back and forth for the past couple of days and haven't caught anything noticeable.

    I checked my system order and it looks identical to what it used to be and what it's coded to be. So that doesn't seem to be the issue.

    I'm thinking it might be a timing issue related to how I'm forcing everything into fixed update. I'm not sure what changed, but my guess unity physics has an internal time delta now thats all out of whack. From some other posts it seems that Unity Physics et al. are releasing the fixed update solution sometime in the next month, so I might just wait to see if that fixes it before I go about spending hours banging my head on my desk.
     
  7. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Yeah we should be releasing the fixed update solution soon, so let's touch base again when that is out. Thanks!