Already a couple of hours I suffer with this tried with the help of Mathf.Clamp, but the turn was not limited to + this kind of addiction appeared. Help please, here's the code:

FixedUpdate() { float yRotGo = rotateY(); Vector3 yrot = new Vector3(0f, Mathf.Clamp(-yRotGo, -60, 60), 0f) * sensetive; } private static float rotateX() { return Input.GetAxisRaw("Mouse X"); } private static float rotateY() { return Input.GetAxisRaw("Mouse Y"); } 
  • In the unit, porov is stored in quaternions, and here is Vector3. Can you add your question, where is yrot used? Because for this fragment I see that everything is correct. Offhand, I can only advise you to put the Clamp inside the rotateY() function, since you have created such a wrapper. - trollingchar

1 answer 1

 if(transform.rotation.y > 60f) { Vector3 yrot = new Vector3(0f, 60f, 0f); } 
  • now only turns left and right) - My Name - noname
  • Well, do as you want. I wrote the sample code, disassemble it further and do it right. There is nothing complicated. - Dodik
  • one
    @Dodik, if the author could do it the way he needs, perhaps this question would not be here? - RiotBr3aker February 6:56 pm