I’m trying to make an enemy that just flies forward in a simple wave pattern. But for some reason my variables are not working the way I would expect them to.
Called from Fixed Update:
newVelocity.x = forwardSpeed;
newVelocity.y = magnitude * Mathf.Cos(Time.time * waveSpeed);
rBody.velocity = newVelocity;
The magnitude works, I can make the wave go out wider or tighter.
But the wave speed just applies the magnitude in reverse. If I increase the wave speed the object just moves in a tighter wave.
I want to adjust it so that magnitude dictates how far up/down the object moves, and waveSpeed dictates how quickly it reaches that peak of how far up/down it moves.
I’m confused here because I’ve done bobbing objects before, and this is the same math I used. I looked around for instructions on how to make something move in a wave pattern, and this is the same math they use. So why is my waveSpeed just constricting the wave?