O'Reilly logo

GameMaker Cookbook by Brandon Gardiner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating enemy pathfinding

In games, there are several ways to move enemies around the playable area. In Chapter 1, Game Plan – Creating Basic Gameplay, we discussed a simple way of using the x and y coordinates. In the previous recipe, we discussed setting paths, which can also be used to shuttle enemies around the screen for your player to avoid or destroy. These are both good options, depending on what you want for your game, but what about enemies that can actually navigate a level, avoid obstacles, and pursue the player? Let's add some depth to a top-down game by creating a slightly more complex enemy AI.

Getting ready

First, you'll need a character object called obj_player that can move in four directions (with collision detection), and an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required