Quantcast
Viewing all articles
Browse latest Browse all 133

Follow rotation on Y axis ONLY clockwise/counterclockwise.

The code I'm using now follows target position and lerps to target rotation. But when it can't catch up, it changes direction since it becomes shorter way to the target. How can I follow rotation on Y axis ONLY clockwise/counterclockwise? I've been trying to find an answer for a long time. Please help. void FixedUpdate() { transform.position = new Vector3(follow.position.x, follow.position.y, follow.position.z); Quaternion followRotation = Quaternion.Euler(new Vector3(followRot.eulerAngles.x, followRot.eulerAngles.y, followRot.eulerAngles.z)); 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>