79381489

Date: 2025-01-23 14:41:57
Score: 0.5
Natty:
Report link

rigidbody.velocity is a vector - its direction defines direction of movement and its length defines speed of movement. Using these properties, you can:

  1. Save up the velocity length (float cachedLength = rigidbody.velocity.magnitude;).
  2. Apply the force you want to modify the direction
  3. Change velocity length to maintain the speed: rigidbody.velocity = rigidbody.velocity.normalized * cachedLength;

This way, you accept change in direction, but not in legth of the vector.

Reasons:
  • Has code block (-0.5):
  • Starts with a question (0.5): is a
  • Low reputation (0.5):
Posted by: Pindwin