[Help] Objects rotate wrong when passing from 0 to 360
I have a chain of gameobjects similar to a snake. The head moves ahead of the segments, and the segments follow. The issue is that whenever the head rotates from 0 to 360 (this is normal for unity. When it reaches 360 and attempts to rotate further, it resets the rotation to zero and continues from there), the segments act as if the head had rotated in the opposite direction all of the way around. The result is this weird looping effect mirrored through all of the segments. Attached below is a GIF of this in action. How do I prevent this? I could do it by rotating the segments in a way that only depends on the relative rotation of the head, but I have no idea how. Each segment currently turns to face the head or the segment in front of it using this line of code: transform.Rotate ((FollowTarget.transform.rotation.eulerAngles - transform.rotation.eulerAngles) / 25);
Thanks in advance!
I think the only good solution for this is to use Quaternions, as I've used them in the past to prevent this problem from happening.
You could probably get some sort of Quaternion.LookRotation towards the follow transform, and then Quaternion.Lerp/Slerp to that rotation ins$$anonymous$$d.
Your answer
Follow this Question
Related Questions
Rotate player with mouse. 0 Answers
Rotating to a certain degree and stopping? 2 Answers
Problems With .rotate behavior 1 Answer
Multiple rotations make a mess! 0 Answers
Check rotation of an obstacle 0 Answers