Harmonic oscillator

Hello everyone, in my game, i’m trying to make an object whick moves as a simple harmonic oscillator. I’m using this code:

transform.position += (moveDirection+Vector3(0,A*Mathf.Cos(Time.time),0)*movementSpeed)*Time.deltaTime*60;

the moveDirection Vector is the normal motion he’ll have, and the other one’s y component it’s varying with the Mathf.Cos of the Time.time variable, so an harmonic motion it’s done.

When I run the game with the editor it works fine, but it seems to be something related to that Time.time part, because when i build the game’s executable, it just doesn’t work as I expected (it follows a different path).

What am I doing wrong?

Thank you

Here’s the answer I found out:

I’ve found it. Time.time it’s actually
the time elapsed since the game
started, not the time since the level
was loaded, so the starting value for
Time.time was different between the
editor and the game because this
wasn’t the initial level.