I am experimenting with multithreading and I want to offload the computation of forces to other threads to be then applied during the fixed update.
Being the RBs states not thread safe, I copy them to custom data structures right at the end of the FixedUpdate, compute the forces in between FixedUpdates and then apply them at the begin of the next FixedUpdate.
This reasoning would work if the copy of the RBs states at the end of the FixedUpate is still valid at the begin of the next one.
According my numerous tests, this is not true. It seems that, at least for WheelColliders, the values change between FixedUpdates.
Is this right? Can you confirm it?
OK, I figured it out.
First of all, it’s interesting to know that the forces are actually applied after all the FixedUpdates but before all the Updates. The bodies update processing actually happen on the main thread and the order is:
Start of the Frame → Fixed Update → Update Body (Physic Process) → Update
Second my problem was due actually to the RB interpolation that’s why the values where changing between fixed updates.
Just as a follow up, the page below gives the execution order of the Unity engine.
Yeah, right. That definitely would help
What do you mean by “RB state”? As far as I understand interpolation would affect the transformation of RBs only, no inner velocities should be changed.
What about all the other rigidBodies that can collide with the rigidBody that will change it’s velocity?