Skip to content

Tag: math

Moving Enemies with Waypoints

Getting enemies to move tends to be one of the more difficult things for me to get right. It just doesn’t always seem natural. And I’m not talking about moving with any type of AI. Just moving around the screen in a pattern.

Sure, straight lines are pretty easy. But games get really boring if all the enemies just go from right to left or left to right.

For this post we’re going to explore moving an enemy through a series of waypoints using ActionScript 3. I’m going to create a movie clip symbol in Flash named Enemy_mc.

Let’s see it

Doesn’t do much good to explain with words. This is what we’re going to create.

One minor difference. I set this demo up to loop so the enemy goes back to its starting position and sets its current waypoint back to 0 when it gets to the last one. The real deal will remove the enemy from the stage.