An Explanation of Multiplication (*) and how it relates to Time, deltaTime and framerate independent motion

Why do you use multiplication in scripting, and how does it work? For instance, if you want to change frame-rate to seconds or something, why would you use the * symbol? Like this:

var speed = 5;

function Update () {
    transform.Translate (0,0,speed * Time.time);
}

From what I understand, that changes `translate` from frame-rate dependency to being time based, but how does it work? Is the * sign, not, like I think it is, actual multiplication, but a sort of 'translate' function?

No, it really is just basic multiplication. I have a feeling that in your example what you really meant to put is Time.deltaTime rather than Time.time.

This is because the value of Time.time increases linearly throughout the course of your playback - counting the seconds elapsed since the playback started, whereas Time.deltaTime gives you a value which is equal to the amount of time elapsed since the last frame.

If your game is running at a steady framerate, the value of Time.deltaTime will maintain a steady value, and it will only increase or decrease in value proportionally to the variations in the framerate that your game is achieving.

So, taking your example (but using deltaTime), and assuming the game is running at, say, around 60 frames per second, the value for deltaTime would be around 0.01666.

This means the object is moved a distance of ( 5 x 0.01666 ) units each frame, and if this happens 60 times a second, it will end up moving 5 units each second.

If the framerate dropped to 20 frames per second, the value of deltaTime would rise to 0.05 (because more time elapses between frames), and you'd end up with the object moving a distance of ( 5 x 0.05 ) units each frame, but because this is now happening only 20 times a second, it still ends up moving 5 units per second.

This is why multiplying your speed by the deltaTime value gives you framerate independent code.