We Value Your Privacy

We and our partners use technology such as cookies on our site to personalise content and ads, provide social media features, and analyse our traffic. Click below to consent to the use of this technology across the web. You can change your mind and change your consent choices at anytime by returning to this site.

Update Consent
Loading ...

How to Get New Enemies on "Game Maker"

Updated July 20, 2017

Games aren't much fun if you only have one enemy, and it's not feasible to manually program the creation of every single enemy in your game. The solution then is to automate the process by getting the game to create the enemies for you, a process called spawning instances. To get enemies spawning in your "Game Maker" game, you will need a "controller" object that will be placed in each room where you want the enemies to appear.

Loading ...
  1. Create a new object called "obj_enemyTimer". This object will not have a sprite associated with it.

  2. Click "Add Event" and select the "Create" event. With this event highlighted, click-and-drag the "Set Alarm" icon from the "Main2" tab to the "Actions" window. A new window will pop up. Enter the time you want the game to wait before making the first enemy. The time is measured in steps; there are 30 steps to a second. If you want a random time, type "random([time])" where "[time]" is the maximum wait period in steps. Note that the "in alarm no:" field is set by default set to Alarm 0. You may change it if you want. Press "OK."

  3. Click "Add Event" again and select "Alarm" and "Alarm 0." Click and drag another "Set Alarm" icon to the "Actions" window and enter the values from the previous step. Also click-and-drag the "Create Instance" icon from "Main1" tab. Choose the enemy you want to spawn from the "Object" drop-down menu and enter the X and Y coordinates where you want the enemy to spawn. Click "OK."

  4. Open the room you want the enemies to appear in. Click-and-drag the "obj_enemyTimer" from the objects list on the left hand side of the screen on to your room where you want the enemies to appear. A small circle with a "?" will appear, indicating that the object is there but has no sprite. The circle will not be visible when you play the game.

  5. Tip

    You can use multiple alarms in the same enemy timer object to control the spawning of different enemies. Use the random() function in the timer lengths and object X & Y coordinates to make your game a bit less predictable.

Loading ...

Things You'll Need

  • Enemy you want to spawn

About the Author

Brian Hagan

Brian Hagan has been writing fiction since 2007, most of it interactive in nature. He also serves as an instructor at the Art Institute of Pittsburgh, where he teaches 3D art, animation, interactive storytelling and design. Hagan holds a master's degree in entertainment technology from Carnegie Mellon University.

Loading ...
Loading ...