- Home /
Question by
MagisterTerran · Apr 08, 2020 at 12:11 AM ·
rotationrigidbody2deulerangles
Limit z rotation of an object
Hello
I am developing 2D game an I have an object to jump on. in rigidbody2D I freeze x and y but not z and I limit z in the script as :
private void FixedUpdate() { Vector3 euler = transform.eulerAngles; if (euler.z > 180) euler.z = euler.z - 360; { euler.z = Mathf.Clamp(euler.z, -35, 35); transform.eulerAngles = euler; } }
it can limit the z when player jumps on it but y and z changing it flies off screen do you know why would it move on x and y while they are selected freeze on the inspector.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612230806im_/https://answers.unity.com/themes/thub/images/avi.jpg)