That could be done in a number of ways. Creating a temporary instance and using that to respawn the enemy is the most versatile and the easiest method. Create a new object, call it
obj_TempEnemy or something.
When the enemy instance is destroyed, create an instance of this object. You could use the Destroy event for that. Using a
with statement, assign a variable to
object_index of the calling enemy instance. You could do that by using the
other keyword which refers to the calling instance inside a
with statement. For example, if you put this code in the Destroy event of
obj_Enemy1, then
other.object_index would return
obj_Enemy1.
Code:
with (instance_create(x, y, obj_TempEnemy)) {
alarm[0] = 10 * room_speed;
my_obj = other.object_index;
}
Then using the Alarm 0 event of
obj_TempEnemy, you could do this:
Code:
instance_create(x, y, my_obj);
instance_destroy();
What the above code does is that it creates an instance of the object that it was created by, then destroys itself, for it is no longer needed.