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

Rotate clockwise/counterclockwise using Quaternion.Slerp()

$
0
0
I am using Quaternion.Slerp() to rotate an object towards player's rotation on Y axis. But if the player's rotation goes too far it changes the direction to take the shortest path. I want to rotate the object clockwise if the player is rotating clockwise and vice versa. Here's the code: void FixedUpdate() { transform.position = new Vector3(follow.position.x + posOffset[0], follow.position.y + posOffset[1], follow.position.z + posOffset[2]); Quaternion followRotation = Quaternion.Euler(new Vector3(followRot.eulerAngles.x + rotOffset[0], followRot.eulerAngles.y + rotOffset[1], followRot.eulerAngles.z + rotOffset[2])); transform.rotation = Quaternion.Slerp(transform.rotation, followRotation, followRotationSpeed * Time.fixedDeltaTime); }

Viewing all articles
Browse latest Browse all 133

Trending Articles



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