Hi,
I have a character which can walk along a wall as well as the ground with no problems. While I don’t have any problems with the character’s rotation itself, I am having trouble with the numerical values of its rotation when it is on the wall.
When I rotate my character everything looks fine in the game, it can make a full circle. However when I look in the inspector at the transform’s rotation, it “ping-pongs” between 270 and 90. if I rotate in one direction continuously, the inspector value will go up to 90, but then as I keep rotating, starts going backwards back down to 0 and then down further towards 270.
Why is this happening and how can I fix it? I need to have the correct rotation value because it is used by something else in my game.
It doesn’t happen when the character is on the ground, only when they are on the wall.
when on the ground it rotates through the y axis, and when on the wall it rotates through the x axis. The same thing happens whether I am rotating the character in gameplay, or using the gizmo in the scene view.
Any help much appreciated! ![]()
Thanks for the response :) I know it's probably a bit difficult to understand just from reading. If I rotate through the x axis, the y and z values stay the same. When unity is representing the same values differently, I think at least two axes need to change? I want to try the method you're suggesting, though to use it for my purposes I'd need to be able to use Quaternion.angle to check just one axis rather than all 3. Is this possible, or should I be using something different to Quaternion.angle altogether?
– OkidoAt least the way I was thinking about it, you would still use eulerAngle on the inner object, but it would always be of the form (0, y, 0) where only y is non-zero and changing. This is then the value you are manipulating and/or checking and you shouldn't have to use Quaternion.Angle() to compare anything, just directly compare the y values.
– Michael-Thomas