Point Light slowing rotation?

Hiya

I’m rotating an object which has a number of point lights attached with the object as parent. The lights are blinking with a script. Issue is: When the lights blink on, the rotation speed of the object slows down, any reasons for this beyond simple FPS issue due to adding lights?
Scripts below.

Rotate script:

var rotateSpeed : float = 1.5;

rotateSpeed = rotateSpeed * Time.deltaTime;

function Update () {
transform.Rotate (0,0,rotateSpeed);
}

Light Blinker:

InvokeRepeating("Blink", 1, 1);

function Blink () {
light.enabled = !light.enabled;
}

your code is wrong.
the *Time.deltaTime must be in the update function as it changes each frame

as the fps will be lower with the light present, the rotation changes too if you do it by a fixed amount per frame instead of fixed per second

Your rotation code is frame rate dependent. Adding a light lowers the frame rate (as it is more expensive to render) and therefore also slows down your rotation.

To make your rotation frame rate independent, change your code to:

var rotateSpeed = 1.5;

function Update () 
{
    transform.Rotate (0,0,rotateSpeed * Time.deltaTime);
}

Time.deltaTime returns the time since the last frame and as a result varies over time.

As a side node: it is really never a good idea to have lines of code (that don’t start with var) outside of functions in java script. You can never really know when the code will be executed or even if the functions and values you use have a sensible value.

Edit: and as usual, dreamora is quicker :wink:

Thanks guys.