Introduction: GameMaker: How to Make Enemies Walk Toward You Avoiding Walls

Hi. This is chessru. I've always tried to figure out how to do what the title states. Now, here it is!

Step 1: Create the Objects

First things first. We need enemies and a player. Program the player for movement and shooting commands(which I assume you know how to do). Then program the enemy for collision effects, such as what if I hit the player, or what if a bullet hits me etc. As you can see, I have programmed player and guard objects.

Step 2: Step 2: Using the "Step Avoiding Tool"

Open the guard programming, and find the Step avoiding block under the "move" tab. It should be at the bottom right. Create a "step event" and then drag the block into the event.

Step 3: Step 3: PROGRAM DAT BLOCK

Now, in this block, there is a slot for x and y coordinates, as well as speed and avoid. Program the x and y coordinates for your object's coordinates (playerobjectname.x and playerobjectname.y should be the correct syntax, just enter that into the x and y coordinates slot), create a speed, and then do avoid solid objects only. Make sure your walls are solid. Now, your guards will run at you avoiding walls!