rotating directional light

I want my directional light to rotate on the y-axis but every time I go to play the game it will not rotate. what is wrong with my script?

//Rotate always
var rotateSpeed = 0.5;

function Update() {
        // Rotate around y-axis
        transform.Rotate (0, Input.GetAxis ("Horizontal") * rotateSpeed, 0.5) ;
}

There is no error.

2 Answers

2

I think you want to multiply that speed by Time.deltaTime, but you know you can also animate this with the Animation Editor (Ctrl-6)

It's framerate-dependent. It's rotating a set amount every frame, which is not what you want. Use rotateSpeed * Time.deltaTime, and then the value for rotateSpeed should be the number of degrees per second, so a value of 90 for example would make a complete revolution in 4 seconds. "0.5" should also be multiplied by Time.deltaTime, though I don't know what your intentions are for that. (0.5 what?)

0.5 is suppost to be the speed that i want my light to rotate.

Yes, but speed in what units? Degrees per second?