I’m writing some custom movement code for a 2D platformer character, using a kinematic Rigidbody and a C# script that can call SweepTest() and MovePosition() two or more times each during its FixedUpdate() function. However, calling rigidbody.MovePosition() doesn’t seem to immediately update the rigidbody’s position variable to the new position. For example the following function will print the same value for position 1 and position 2:
void FixedUpdate () {
Debug.Log("Position 1: " + rigidbody.position);
rigidbody.MovePosition(rigidbody.position + new Vector3(0.0f, 1.0f, 0.0f));
Debug.Log("Position 2: " + rigidbody.position);
}
I assume this means that the Rigidbody is only being moved at the end of the physics step. If this is the case, how can I move a kinematic Rigidbody and call SweepTest() from its new position in the same FixedUpdate() call?