How to assign a rotation stop in a camra fps?
i made this script and the camera rotates 360 ° on the x axis and on the y axis , How to make it stop spinning after a certain angle?`
void Update () {
h = Horizontalspeed * Input.GetAxis("Mouse x");
v = Verticalspeed*Input.GetAxis ("Mouse Y");
transform.Rotate(0, h, 0);
FPScamera.transform.Rotate(-v, 0, 0);
if (Input.GetKey(KeyCode.W))
{ transform.Translate(0, 0, 0.2f);
} else {
if (Input.GetKey(KeyCode.S))
{
transform.Translate(0, 0, -0.2f);
}
else if (Input.GetKey(KeyCode.A))
{ transform.Translate(-0.2f, 0, 0);
}else if (Input.GetKey(KeyCode.D))
{ transform.Translate(0.2f, 0, 0); }
else if (Input.GetKey(KeyCode.LeftShift))
{ transform.Translate(0, 0, 0.5f); }
Comment
Your answer
Follow this Question
Related Questions
OnMouseDown raycast doesnt match UI crosshair 1 Answer
camera script problems and can't see the selected object 0 Answers
How can i move my camera forward independent of its pitch? 1 Answer
Partial synchronization of camera with the bone of the head or other object 0 Answers
FPS Idle Movement when not walking? 0 Answers