- Home /
Question by
thepotatisbulle · Jan 31, 2017 at 09:14 PM ·
c#cameracontroller
How do I limit my chracters rotation on the X axis?
I have set up a somewhat working Fps controller. Now I just need to limit the rotation on the X axis. I tried using an if statement but I can't get it to work. How do I limit rotation on the X axis?
Vector3 mouseInputY = new Vector3(Input.GetAxisRaw("Mouse Y"), 0.0f,0.0f);
if (transform.rotation.x > 90f | transform.rotation.x < -90f)
{
null;
}
else
{
transform.Rotate(-mouseInputY * turnSpeed * Time.deltaTime);
}
Comment
Answer by IgorAherne · Jan 31, 2017 at 11:52 PM
Don't confuse | with ||, the latter is what you should be using. Single dash is the binary operator, for doing all weird things with bytes
instead of null, use return or return null if applicable
Your answer