Rotate only Y axis?

Hello, I've this script for my camera right now.

var speed : float = 5;

function Update() {
transform.Rotate(0, Input.GetAxis("Horizontal")*speed*Time.deltaTime, 0);
}

I want to be able to rotate my camera along the Y axis when I press the left or right arrow key.

Right now, when I rotate it via the arrow keys, it rotates all 3 axes. I want only axis Y to be affected. I tried going to edit->inputs->horizontal and changing the axis to Y, but it doesn't work.

Help, anyone? =)

1 Answer

1

Try `transform.Rotate(0, Input.GetAxis("Horizontal")*speed*Time.deltaTime, 0,Space.World);`

Yes, it works! Thank you! =)

–