Simulating a sine wave/oscillating pattern for enemies
Posted
by
Sun
on Game Development
See other posts from Game Development
or by Sun
Published on 2012-09-16T16:39:48Z
Indexed on
2012/09/17
15:54 UTC
Read the original article
Hit count: 149
I'm creating a simple top down shooter, right now I have an enemy which simply follows the player. I'd like to change things up and have the enemies move towards the player but in a wave like motion. I have looked at some similar questions like this but they don't take into account for the Y changing. How can I simulate a wave like pattern for my enemies whilst they are homing into their target.
Edit:
Sample code
In my update method I have the following:
Vector2 trackingPos = position - target;
trackingPos.Normalize();
position -= trackingPos * elaspedTime * speed;
© Game Development or respective owner