How do you change the velocity of an object moving in a sine wave?
So I'm in the middle of prototyping my first game in Unity, it's a sort of a runner and the enemies move towards the player, nothing big :)
The problem is that one of them moves in a sine wave pattern, but it is too fast. From what I've gathered:
In amp*sin(Time.time), "amp" changes the amplitude of the sine wave.
In sin(Time.time*freq), "freq" changes the frequency of the sine wave
I want to keep the frequency and the amplitude as stated by those variables, but I want to be able to control how fast the object traverses the wave. Anyone knows how to do it?
Here's the code that I'm using:
Vector3 vectorStep = new Vector3(
1,
xAmplitude*Mathf.Sin(time *xFrequency),
0);
transform.position += vectorStep;
Comment