- Home /
Make object only rotate in 90 degree increments
How do you make a GameObject only be allowed to rotate in 90 degree increments? And it can only rotate about the Y axis. Like it can only rotate around the Y axis, but only in 90 degree increments.
Answer by Arisstephenson · Jul 19, 2018 at 03:25 AM
If you are talking about in the editor, you can change the snapping increments in your snap settings:
If you want to do it in play mode, as in restricting the y movement, you could use something along these lines:
Vector3 Snap (Vector3 angle, float degrees) {
angle.y = Mathf.Round(angle.y * degrees) / degrees;
return angle;
}
Your answer
Follow this Question
Related Questions
how to get the absolute direction? 1 Answer
Flip over an object (smooth transition) 3 Answers
How to fix rotation while moving character 0 Answers
How to set a single-axis rotation and not change the others axes 1 Answer
Is there a way to lock my camera's rotation and movement on certain axis? 2 Answers