Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Confused about practical use of substepping Unity Physics
#4
(01-07-2020, 03:09 AM)protomenace Wrote: Thank you so much for all the information Jose. With what you said I was able to get my drone hovering perfectly again by moving my FixedUpdate logic into a callback handler for ObiSolver.OnSubstep.

However I noticed one thing when doing this, it seems to break Rigidbody interpolation. That is, my drone has a Unity Rigidbody with interpolation enabled, and normally the drone's motion looks very smooth. But when I'm using the ObiSolver and responding to OnSubstep events, the apparent motion of the drone becomes very discrete, as though rigidbody interpolation is no longer enabled. This is especially noticeable in my game because I have a mechanic whereby the game enters slow motion (1/100th of realtime), and you can very clearly see the drone jumping around in space every time the updater calls Physics.Simulate().

Is this a known issue with Unity physics substepping in Obi? Is there a normal workaround for it to get smooth motion again?

Here's a video of what I'm talking about. In the first half of the video, I have substepping Unity physics enabled and you can clearly see the lack of interpolation. In the second half of the video, I disable it and you can see the normal, smooth motion of my rigidbody. (I'm also disabling a custom component I made which notifies my other scripts that Unity physics substepping is happening so they will switch from processing inside FixedUpdate() to OnSubstep)


Hi there!

This looks like a bug/overlook in Unity, I'd expect interpolation to happen in LateUpdate() after all physics calls for the frame have been done. This is what we do in Obi, and what is usually done in all physics engines. Interpolation works by:

- Storing the physics state at the end of the previous frame.
- Storing the physics state at the end of the current frame.
- Interpolate and render a state between both, using the difference between frame time and simulated time. So if you've only simulated 50% of the frame time, the rendered state would be a 50/50 blend of the past and the current physics states.

This can be done regardless of where/when you update the simulation since all you care is the state at the end of each frame, so I see no reason for manual updating to break interpolation. Will test it and get back to you asap.
Reply


Messages In This Thread
RE: Confused about practical use of substepping Unity Physics - by josemendez - 01-07-2020, 07:57 AM