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