Order of execution: AddForce, rigidbody movement, velocity update?
I'm trying to do a predictive pathtrace of a rigidbody which I'm adding force to each FixedUpdate based on it's position - gravity stuff. It's looking passable, but my simulation isn't 100% accurate, which is annoying. I know I could start working on my own physics and not use rigidbodies, but I'd rather avoid that if possible.
My problem is, I have no idea what the execution order within "internal physics" is. I think I'm correct in assuming that the example below will add a force in the following InteralPhysicsUpdate? Maybe acceleration works differently?
Debug.Log(rigidbody.velocity); //eg 1,1,1
rigidbody.AddForce(Vector3.one, ForceMode.Acceleration);
Debug.Log(rigidbody.velocity); //still 1,1,1
Now, the added force may or may not add to the change in position for the rigidbody in the following InteralPhysicsUpdate - depending on the execution order. Either the rigidbody moves, then forces are added to update velocity, which will carry over to the next FixedUpdate, or forces are added before the rigidbody moves. It shouldn't cause me so much trouble.
So, can anyone help me understand what is happening under the hood of the InteralPhysicsUpdate? Is the velocity updated from script forces before or after rigidbodies move?
I've changed my script to work with either scenario but it just doesn't work as I'd hope. My problem might be something else entirely (looking at floating points), but I suspect the physics might behave differently than I expect!