Hi, i’m fairly new to Physics engines and how do they do their tasks, but i’m pretty sure my idea is doable.
Besides the fact that when experimenting with deterministic physics simulation i think i found a bug, where a rigidBody with collision Mask = 0 collides with a static one with mask = 0 behaves differently than if the first had mask = 1.
So yeah, this is about replicating physics.
I have a fixedUpdate function inside the normal update one, if time elapsed > fixedTimestep it adds 1 to physics frames and also calculates how many frames it went past.
So if it took 40ms last update it went past 2 times (15ms fixedTimeStep).
I also have an array of booleans, containing the input for each frame to be processed, every physics frame it takes the input from inputs[physicsFrame] and apply a force to rigidBody if it’s true (force is always the same cause it’s a fixedUpdate).
Then i have two capsules with different mask, so they can overlap to show the result of simulation.
The second capsule inputs array starts with more 0s to delay the first capsule inputs from the other.
Let’s say the second capsule needs to process 10th frame’s input, and the update loop takes 40ms, it would need to also process 11th. If i apply them both in one update loop, they get desynced.
Otherwise if the update never exceeds 1 physics frame per update, it works perfectly, both capsules end at same position.
Is there any Solutions available at the moment?
I think there’s the need of a simulatePhysics() function.
I hope i explained everything well enough.