Question by
Hakkemet · Feb 09, 2016 at 09:45 PM ·
rotationeulerangles
How do I limit transform.LocalEulerAngles.x? [Solved]
This is my code:
public float yAngleLimit, sensitivity;
void Update(){
float rotationY = -Input.GetAxis ("Mouse Y") * Time.deltaTime * sensitivity;
transform.localEulerAngles = new Vector3 (transform.localEulerAngles.x + rotationY, 0, 0);
}
I want to limit on X Rotation. Thanks
Comment
Best Answer
Answer by Hakkemet · Feb 10, 2016 at 02:42 PM
void Start(){
sensitivity = 0;
tiltAngle = 0;
}
void Update() {
tiltAngle += Input.GetAxis("Mouse Y");
transform.rotation = Quaternion.Euler(tiltAngle + Time.deltaTime + sensitivity, 0, 0);
tiltAngle = Mathf.Clamp (tiltAngle, minY, maxY);
}
This is my solution, thanks
Answer by Paulius-Liekis · Feb 10, 2016 at 10:07 AM
transform.localEulerAngles = new Vector3 (Mathf.Clamp(transform.localEulerAngles.x + rotationY, min, max), 0, 0);
?
Your answer
Follow this Question
Related Questions
UI compass pointing to a 3D object 0 Answers
Rotation problem 0 Answers
Quaternion.LookRotation on only one axis? 1 Answer
Quaternion.Euler doesn't work right? 2 Answers
Character rotation is jittery 1 Answer