Everything was working before 5.2.2.
I have moving platforms with a rigidbody2d with isKinematic enabled, a script uses MovePosition on the rigidbody2d to move the platform but I also need the velocity returned, but since version 5.2.2 velocity is always 0
Any ideas why?
MovePosition leaving the velocity it calculated was a regression bug that was fixed, it wasn’t a feature. It now correctly restores the velocity that was there prior to the MovePosition (or anything you do whilst it’s working). It had worked like this for a long time but fairly recently was broken.
It was fixed in 5.2.1 Patch 3 (9th Oct 2015).
RN: (697547) - Physics: Restore the Rigidbody2D linear-velocity after a Rigidbody2D.MovePosition has completed.
You could get manually:
private Vector3 latePosition;
public Vector3 velocity;
void Start() {
latePosition = transform.position;
}
void FixedUpdate() {
velocity = (transform.position - latePosition) / Time.FixedTime;
latePosition = transform.position;
}
I Have just reverted back to 5.2.1f1 and it now works as expected.
Although isKinematic is enabled and the rigidbody moves using MovePosition it should return the velocity instead it always returns 0.