I’m using the oft sited (yet probably ham-handed) method of constraining velocity:
if (Mathf.Abs (rigidbody.velocity.magnitude) > maxSpeed){
rigidbody.velocity = rigidbody.velocity.normalized * maxSpeed;
}
Hopefully I’ll work out something a bit more robust in the future, but for now my main problem is that this formula slows down the vertical motion of my jumps. I only want the magnitude of motion across the ground (x and z axes) to be affected by the velocity constraint, not z motion.
I’ve tried setting an “OnGround” bool to use as a second qualifier for the velocity constraint, which is controlled by the OnCollision trio of functions, but there always seems to be at least a frame after the jump impulse is fired where it still thinks it’s in contact with the ground and thus ruins the jump. Any insight out there?