- Home /
Mouse Look Controller that can rotate on the Z axis
Heya all.
I'm looking for a code that will let me rotate my first person controller on the Z axis. I'm making a game where gravity changes and the character needs to be able to rotate to be on his feet again instead of hitting his head on the roof which has now become the floor.
I've already gotten the movement and jumping down, but the default mouse look script refuses to let me rotate on the Z axis no matter what. I looked at it's code, it's a bit complex for me. I get that it's trying to keep me straight up. That's fine, I like that part, I just want a way to disable that for a bit to flip the character and turn it back on after.
Answer by nasapc123 · Sep 06, 2011 at 04:32 AM
hey is this roughly what you want? change the block which reads:
else if (axes == RotationAxes.MouseX){
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
}
into
else if (axes == RotationAxes.MouseX){
transform.Rotate(0, 0, Input.GetAxis("Mouse X") * sensitivityX);
}
is that what you want?
That wasn't quite what I was looking for. Thanks for the help though.
I eventually figured it out after lots of trial and error. The line that was giving me all the trouble was the "originalRotation" code that is built into the $$anonymous$$ouse Look script. Original rotation starts with 0,0,0,1 and tries to never change. So I just made a code that would change the Z on that on demand.