#how can ı change the direction of velocity
1 messages · Page 1 of 1 (latest)
can i see your code
changing velocity:
// rotate velocity
Quaternion deltaRotation = ...
rb.velocity = deltaRotation * rb.velocity;
// use different direction vector but keep speed
rb.velocity = direction.normalized * rb.velocity.magnitude;
you can also find the rotation between 2 vectors
https://docs.unity3d.com/ScriptReference/Quaternion.FromToRotation.html
Another solution (that doesn't require the delta rotation) could be to create a new vector from the original velocity's magnitude and transform.forward, and set that as the new velocity.