Mouse look/rotate

I need help with making script that will rotate character left and right based on Mouse Y axis movement and that will look up and down based on Mouse X axis movement. I’ve tried several methods including Ray, Quaternion and transform.rotate and nothing works for my problem.

Why would you want the mouseX(left and right) to look up and down? and mouseY(up and down) to look left and right??? For one, there’s a built in Mouselook script in the CharacterController asset for unity. Horizontal Axis Input is for “a” and “d” and left and right arrows. Vertical Axis is “w” and “s”, and up and down arrows. You need GetAxis(“Mouse X”) or GetAxis (“Mouse Y”). And if you use this in an IF statment you need to ask if it that axis is greater or less than zero.

if(Input.GetAxis("Mouse X") < 0)
    transform.Rotate(Vector3.up) * speed;
if(Input.GetAxis("Mouse X") > 0)
    transform.Rotate(Vector3.up) * -speed;

That’s just an EXAMPLE. There are many ways. I say Vector3.up there because that’s the y axis of your player or w/e your rotating, meaning it will rotate left and right.

You could also do it like:

transform.localEulerAngles.y+= Input.GetAxis("Mouse X") * speed;

Of course in C# you have to put localEulerAngles in a temp var but that’s not the question so I’ll stick w/ it. To get you started I’ll just lay out that you need to use the mouse axes I named above. If you need help beyond that let us know.

Maybe this is too late but for anyone watching this out there you could simply make a “mouseInput” variable (of course you pick the name) and assign it to Input.GetAxis’s the set your transform.Rotate(mouseInput); of course im using C# you might have to make some slight modifications to it