Phong13/BulletSharpUnity3d

callback like fixedupdate of unity?

Opened this issue · 1 comments

i would need a callback like fixedupdate from the physics engine. can i just use fixed update or is there something hidden somewhere?

is the BPhysicsWorldLateHelper doing the stepping of the physics engine? but why is it done both in update and fixedupdate?

Hi Fred, yes, you can used Fixed Update. The design is for BPhysicsWorld to execute early and fire the collision events. Then BPhysicsWorldLateHelper executes late and steps the simulation. You can check the Script Execution Order settings to see. The Simulation is stepped in Update as well as FixedUpdate for interpolation. Notice that deltaTime is being passed in as the first argument and that StepSimulation returns numSteps. The simulation step only triggers if enough time has elapsed to cross an m_fixedTimeStep boundary. You might have multiple Update called between m_fixedTimeStep calls. Or you might have a very slow frame and StepSimulation needs to do multiple StepSimulation steps to catch up. Calling StepSimulation in Update lets Bullet interpolate the positions. Without it there can be visible jitter caused by Update and FixedUpdate being out of synch.