Quantcast
Channel: Questions in topic: "quaternion.slerp"
Viewing all articles
Browse latest Browse all 133

How to make quaternion.slerp stop snapping

$
0
0
So I have this code to rotate a ship so it faces the player in a 2D game (all in Z plane): Quaternion desiredQuaternion = Quaternion.LookRotation(-desiredVector, -Vector3.forward); selfTransform.rotation = Quaternion.Slerp (selfTransform.rotation, desiredQuaternion, Time.deltaTime * turnSpeed); desiredVector is the vector from the ship to player, selfTransform is the transform of the ship (caching), and turnspeed is the float controlling the turn speed. The ship rotates correctly and faces the player, but whenever it passes straight up or down, it locks to that angle until the vector is at least 45 degrees or so past.

Viewing all articles
Browse latest Browse all 133

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>