- Home /
This question was
closed Feb 28, 2017 at 02:59 PM by
NovaDrox for the following reason:
I figured it out
Question by
NovaDrox · Feb 28, 2017 at 01:19 AM ·
cameracamera rotateclampclamped rotation
How to Math.f Clamp this
I don't know how to clamp this. Can someone help me out.
float RotY = Input.GetAxisRaw("Mouse X");
Vector3 RotateY = new Vector3(0f, RotY, 0f) * TurnSpeed;
float RotX = Input.GetAxisRaw("Mouse Y") * TurnSpeed;
RotX = Mathf.Clamp(RotX, -AngleLimit, AngleLimit);
Vector3 RotateX = new Vector3(RotX, 0f, 0f) * TurnSpeed;
transform.Rotate(RotateY);
Cam.transform.Rotate(-RotateX);
Comment
I'm not sure I understand correctly your question. The way you used $$anonymous$$athf.Clamp
, you limit the possible values of RotX
between -AngleLimit
and AngleLimit
. Is this what you wanted to achieve?
Follow this Question
Related Questions
I can't figure out how to clamp it 2 Answers
Bizzare problem with limiting camera veritcal rotation 2 Answers
Clamp horizontal rotation based on current direction 0 Answers
Clamping RotateAround 1 Answer
Clamp Camera Angle not Working 2 Answers