graphicsdump
Member
Hi all!
I currently have enemy objects (small rockets) that are spawned using a time interval, and when an enemy object's x position matches the player's x position, I have it working where the enemy object's direction changes from 0 to 90, flying towards the player.
The problem is, every enemy object instance flies up towards the player once the first instance's x position reaches the player object's x position.
I've been trying to use instance_id, instance_find, etc., but everything I've tried failed. I tried reading through a of posts here for help but haven't found anything that worked.
Here's what I have that works so far:
o_enemy2 Create:
o_enemy2 Step:
objSpawn2 Create:
objSpawn2 Alarm 0:
I currently have enemy objects (small rockets) that are spawned using a time interval, and when an enemy object's x position matches the player's x position, I have it working where the enemy object's direction changes from 0 to 90, flying towards the player.
The problem is, every enemy object instance flies up towards the player once the first instance's x position reaches the player object's x position.
I've been trying to use instance_id, instance_find, etc., but everything I've tried failed. I tried reading through a of posts here for help but haven't found anything that worked.
Here's what I have that works so far:
o_enemy2 Create:
GML:
hp_ = 4;
direction = 0;
speed = -2
Code:
if hp_ <= 0 {
instance_destroy();
}
if o_enemy2.x == o_player.x { ///launch rocket when enemy x position = player x position
direction = 90; ///fly upwards
speed = 4; ///at speed of 4
}
Code:
alarm[0] = random_range(room_speed*.5, room_speed*3);
Code:
instance_create_layer(x, y, "Enemies", o_enemy2);
alarm[0] = random_range(room_speed*.5, room_speed*3);