game-developmentspawngame-makergame-maker-studio-2game-maker-language

Spawning Enemies on Game Maker


I am coding a game on game maker studio in which I want a number of enemies to be spawned randomly on my grid every time the game is run. However, I am only getting one enemy on my map each time I run it.

Below is the Create instance for my enemy object.

x_speed_ = 0;
y_speed_ = 0;
max_speed_ = 1.5;
move_speed = 1;
acceleration_ = .3;
path_start(follow_path, move_speed, continue_path, true);

Also, this is the code in the Create instance for the level that is used to place the enemies on my grid.

for(var n = 1; n < 8; n++) {

    i = irandom_range(1, grid_width-2);
    j = irandom_range(1, grid_height-2);
    instance_create_layer(i, j, "Instances", object_enemy);

}

Can anyone spot the reason why I'm not getting multiple enemies in my level?


Solution

  • I can think of 2 possible scenarios in the given context: