I have many enemies but I would like to use one object to respawn enemies gms 1.4

Imiglikos

Member
Hello everyone,

I have many enemies in the game and I have created an object for each of them separately so that each enemy can respawn after death. Is there a way for me to have only one object to respawn enemies? instead of creating dozens of objects?
Thank you in advance for helping everyone.

currently the code looks like this

obj_enemy

create

GML:
dead=false;

step

GML:
if hp <= 0 {
 
 
 instance_destroy();
 
 dead=true;
 

  with instance_create(x,y,obj_entity_die)
 
 
  {
  sprite_index = spr_enemy_die;
  image_speed=1;
  image_xscale = other.image_xscale;
  image_yscale = other.image_yscale;
 
 
  audio_play_sound(snd_enemy_die, 1, false);
 
   }
}


// respawn enemy
if (dead == true)
{
 
 
 instance_create(x,y,obj_respawn_enemy);
}

obj_respawn_enemy

create

GML:
alarm[0]=20*room_speed
dead = false

alarm[0]

GML:
instance_create(x,y,obj_enemy)

step

GML:
if (dead = true)
{
alarm[0] = 90
dead = false
}
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I have many enemies in the game and I have created an object for each of them separately so that each enemy can respawn after death. Is there a way for me to have only one object to respawn enemies? instead of creating dozens of objects?
Before going any further... Is there any real reason why you want to do this? Is having "spawner" instances causing problems? I ask, because often people try to optimise things when it isn't necessary and end up over-complicating something that is incredibly simple to start with. At the moment, what you have is perfectly fine and probably works perfectly, so do you NEED to change it? Is it causing you an issue? If the answer to these questions is "no" then why change it... :)

That said, let's quickly offer a solution to the question you have. If it was me, I'd have a spawn control object with a "priority queue" data structure in it and a timer variable that counts up every step. Then when an enemy dies, I'd create an array, where: [0] = object index, [1] = x, [2] = y. You can add further information as required into this array. This array is then added to the priority queue and the priority is set to the current value of the timer variable plus the time you want to take to have the instance spawn. Then the controller simply checks the queue each step, comparing the current timer variable value with the min priority queue value, and if they are the same, then get the array for the priority, delete it from the queue and spawn a new enemy instance using the array data.

Hope that helps!
 

Imiglikos

Member
Before going any further... Is there any real reason why you want to do this? Is having "spawner" instances causing problems? I ask, because often people try to optimise things when it isn't necessary and end up over-complicating something that is incredibly simple to start with. At the moment, what you have is perfectly fine and probably works perfectly, so do you NEED to change it? Is it causing you an issue? If the answer to these questions is "no" then why change it... :)

That said, let's quickly offer a solution to the question you have. If it was me, I'd have a spawn control object with a "priority queue" data structure in it and a timer variable that counts up every step. Then when an enemy dies, I'd create an array, where: [0] = object index, [1] = x, [2] = y. You can add further information as required into this array. This array is then added to the priority queue and the priority is set to the current value of the timer variable plus the time you want to take to have the instance spawn. Then the controller simply checks the queue each step, comparing the current timer variable value with the min priority queue value, and if they are the same, then get the array for the priority, delete it from the queue and spawn a new enemy instance using the array data.

Hope that helps!

This solution of mine does not cause problems, only that for each enemy I have to create such a respawn as a separate object and I already have a lot of them. I do not know if it will affect the game performance. Hence, I started the topic ;-)
 

Gamebot

Member
EDIT: I miss read your code at first.

I am just curious how many objects you have and why you would need a spawner for each. As @Nocturne said if there arn't that many I wouldn't worry about it. However, you could use a parent object assuming your "spawn" timer and code is the same. Just create a parent object ( obj_par_enemy ) put into it any code that is the same for all of your other object code then tell those objects they have a parent.

parent.png


// OLDER STUFF //
You could write your spawn code using a script then simply call that script for each instance if your that worried about it. A simple script might look like this. However you would need to change things around to make it your own.

Calling:
scr_spawner( object_index );

scr_spawner
GML:
var free = false;

  while (!free) {

    var xx = random ( room_width )

    var yy = random ( room_height )

    var place = instance_position( xx, yy);


    if (place == noone) {

     instance_create_depth( xx, yy, 0, obj);

     free = true;

    }

  }
 
Last edited:

Imiglikos

Member
You could write your spawn code using a script then simply call that script for each instance if your that worried about it. A simple script might look like this. However you would need to change things around to make it your own.

GML:
function spawner( obj ) {   // Just put in object_index when calling //

  var free = false;

  while (!free) {
    var xx = random ( room_width )
    var yy = random ( room_height )
    var place = instance_position( xx, yy);
   
    if (place == noone) {
     instance_create_depth( xx, yy, 0, obj);
     free = true;
    }
  }


}

So the script can be used in the creacion code of the enemy that I would like to respawn anyway?
 

Imiglikos

Member
I reedited my first post didn't quite get it done before you responded.
that is, I create a parent ok, e.g. par_respawn_enemy and set it for all enemy that I would like to reborn after death:)


obj_enemy

step

GML:
if hp <= 0 {
 
 
 instance_destroy();
 
 dead=true;
 

  with instance_create(x,y,obj_entity_die)
 
 
  {
  sprite_index = spr_enemy_die;
  image_speed=1;
  image_xscale = other.image_xscale;
  image_yscale = other.image_yscale;
 
 
  audio_play_sound(snd_enemy_die, 1, false);
 
   }
}


// respawn enemy

function spawner( par_respawn_enemy ) {   // Just put in object_index when calling //

  var free = false;

  while (!free) {
    var xx = random ( room_width )
    var yy = random ( room_height )
    var place = instance_position( xx, yy);
 
    if (place == noone) {
     instance_create_depth( xx, yy, 0, obj);
     free = true;
    }
  }


}
 

Gamebot

Member
That's pretty much it except assuming you are using multiple enemies with different names obj_enemy1, obj_enemy2.... I have not tested but you could try replacing in your instance_create line with:

instance_create( x, y, object_index );

I'm assuming your using GMS 1? As your functions are slightly different.
 

Imiglikos

Member
That's pretty much it except assuming you are using multiple enemies with different names obj_enemy1, obj_enemy2.... I have not tested but you could try replacing in your instance_create line with:

instance_create( x, y, object_index );

I'm assuming your using GMS 1? As your functions are slightly different.
yes i am using gms 1.4
 

Imiglikos

Member
That's pretty much it except assuming you are using multiple enemies with different names obj_enemy1, obj_enemy2.... I have not tested but you could try replacing in your instance_create line with:

instance_create( x, y, object_index );

I'm assuming your using GMS 1? As your functions are slightly different.

Yes, I use enemies with different names, so the example code should look like this?

obj_enemy1

step

GML:
if hp <= 0 {


instance_destroy();




  with instance_create(x,y,obj_entity_die)


  {
  sprite_index = spr_enemy_die;
  image_speed=1;
  image_xscale = other.image_xscale;
  image_yscale = other.image_yscale;


  audio_play_sound(snd_enemy_die, 1, false);

   }
}


// respawn enemy

function spawner( par_respawn_enemy ) {   // Just put in object_index when calling //

  var free = false;

  while (!free) {
    var xx = random ( room_width )
    var yy = random ( room_height )
    var place = instance_position( xx, yy);

    if (place == noone) {
     instance_create_depth( xx, yy, 0, obj_enemy1);
     free = true;
    }
  }


}

Hmmmmm...this function does not work in gms 1.4: /

GML:
function spawner
 
Last edited:

Gamebot

Member
I think the easiest would be to create a parent and put your spawn code in it. I did realize later you were using 1.4 not 2.3 for the script. I'll change that in a moment.
Create an object such as obj_enemy_par or obj_enemy_spawner.... and put into it any spawn code along with any code that is the same for ALL of your enemies. If there is any code that is different don't put it in your parent. Make sure each enemy has selected under "parent" as shown below the parent object.

Untitled.png

I do remember also that you needed at one point event_inhereted() in each object's create event first line that had a parent, not the parent itself. You may want to look that up to see that actual structure. You might be able to reference "Parent Objects" as some persons like myself are more visual.
 
Last edited:

Imiglikos

Member
I think the easiest would be to create a parent and put your spawn code in it. I did realize later you were using 1.4 not 2.3 for the script. I'll change that in a moment.
Create an object such as obj_enemy_par or obj_enemy_spawner.... and put into it any spawn code along with any code that is the same for ALL of your enemies. If there is any code that is different don't put it in your parent. Make sure each enemy has selected under "parent" as shown below the parent object.

View attachment 43759

I do remember also that you needed at one point event_inhereted() in each object's create event first line that had a parent, not the parent itself. You may want to look that up to see that actual structure. You might be able to reference "Parent Objects" as some persons like myself are more visual.
Thank you i already created a parent and put a spawn code in it in parent step event but this script from you doesn't work because i have gms 1.4

I think the easiest would be to create a parent and put your spawn code in it. I did realize later you were using 1.4 not 2.3 for the script. I'll change that in a moment.
Create an object such as obj_enemy_par or obj_enemy_spawner.... and put into it any spawn code along with any code that is the same for ALL of your enemies. If there is any code that is different don't put it in your parent. Make sure each enemy has selected under "parent" as shown below the parent object.

View attachment 43759

I do remember also that you needed at one point event_inhereted() in each object's create event first line that had a parent, not the parent itself. You may want to look that up to see that actual structure. You might be able to reference "Parent Objects" as some persons like myself are more visual.
Okay I have a parent created which I have placed in all enemies. My spawn code in the event alarm [0] refers to a specific named enemy. So should I insert a reference to the scr_spawner script here?


example


obj_enemy_par

create

GML:
event_inherited();
alarm[0]=20*room_speed
dead = false

alarm[0]
GML:
scr_spawner( object_index );
step
GML:
if (dead = true)
{
alarm[0] = 90
dead = false
}
But I noticed that the script might have errors on this and that line
scr_spawner
GML:
var free = false;
  while (!free) {
    var xx = random ( room_width )
    var yy = random ( room_height )
    var place = instance_position( xx, yy); // here it displays an error
    if (place == noone) {
     instance_create_depth( xx, yy, 0, obj); // here it displays an error
     free = true;
    }
  }
 
Last edited by a moderator:

Imiglikos

Member
Surely, your errors have messages that tell you what's wrong.



You didn't specify an object to check for.



Game Maker Studio 1.4 only had instance_create, right?
you are right. I made modifications to this script now it looks like this

scr_spawner

GML:
var free = false;

  while (!free) {

    var xx = random ( room_width )

    var yy = random ( room_height )

    var place = instance_position( xx, yy,obj);


    if (place == noone) {

     instance_create( xx, yy, obj );

     free = true;

    }

  }

however, when I kill the enemy and try to respawn, an error pops up

GML:
############################################################################################
FATAL ERROR in
action number 1
of Alarm Event for alarm 0
for object  obj_enemy_par :

Variable obj_player.obj(100013, -2147483648) not set before reading it.
 at gml_Script_scr_spawner (line 11) -     var place = instance_position( xx, yy,obj);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scr_spawner (line 11)
called from - gml_Object_ obj_enemy_par _ObjAlarm0_1 (line 3) - scr_spawner( object_index );
That is, as if the variable has not been set, only the question of what must be declared what variable?
In the script I cannot indicate a specific enemy to respawn because the script is supposed to be universal and spawn all enemies that have a parent obj_enemy_par
 

Nidoking

Member
I take it you're not familiar with how script arguments work, then? I don't have a link to the documentation for obsolete versions of Game Maker, but you have to know how to write scripts.
 

Imiglikos

Member
I think the easiest would be to create a parent and put your spawn code in it. I did realize later you were using 1.4 not 2.3 for the script. I'll change that in a moment.
Create an object such as obj_enemy_par or obj_enemy_spawner.... and put into it any spawn code along with any code that is the same for ALL of your enemies. If there is any code that is different don't put it in your parent. Make sure each enemy has selected under "parent" as shown below the parent object.

View attachment 43759

I do remember also that you needed at one point event_inhereted() in each object's create event first line that had a parent, not the parent itself. You may want to look that up to see that actual structure. You might be able to reference "Parent Objects" as some persons like myself are more visual.


I corrected the script, but the problem is that in my code, in alarm 0, the enemy respawns that I killed, and I cannot use this solution for other enemies because only this one enemy will respawn
 

Nidoking

Member
If you want to spawn a particular enemy, you use that enemy type's object index to tell it which enemy to spawn. It's no more or less difficult than that.
 

Imiglikos

Member
If you want to spawn a particular enemy, you use that enemy type's object index to tell it which enemy to spawn. It's no more or less difficult than that.
That's not what I mean, because I sent the enemy spawn code that I wrote
Here on the forum someone designed a script so as not to create dozens of objects to spawn each enemy individually.
The problem is that I put the code as respawn and the script. It does not work.
Is there an effective way for a single object to spawn enemies? Without the need to create dozens of spawning objects?




This should work so that I only have one object that controls enemies spawn. And in the creacion code of each enemy that he wants to spawn, it indicates that he wants to spawn that enemy.
This way, I wouldn't have to create a separate spawn controller for each individual enemy
separately.


Yes, I think maybe this is how it should look like, but it's worse with the implementation of it.
 
Last edited:

Nidoking

Member
Something needs to tell the enemy spawner what kind of enemy to spawn at any time, yes? That is the question you need to answer: "When I am to spawn an enemy, what type of enemy should I spawn?" But don't answer it here; answer it in your game, in code.

But this doesn't make sense:

And in the creacion code of each enemy that he wants to spawn, it indicates that he wants to spawn that enemy.
Creation code/create events don't happen until after an instance is created. So creation code of the enemy instance can't possibly tell a spawner how to create the enemy that contains the code. The problem is that I can't understand what you're saying. Your autotranslator is not working very well. If you're trying to create a generic spawner object that you can place in the game many times, and each instance of that object spawns a single type of enemy, then use Variable Definitions. That is literally what they're for. If you want to have one instance of an enemy spawner object that spawns whatever type of enemy the situation calls for, then it's possible, but not simple. You'll have to find a way to tell the spawner, at a given time, to spawn a particular enemy. That's something you will have to define, because it depends on your game.
 

Imiglikos

Member
Something needs to tell the enemy spawner what kind of enemy to spawn at any time, yes? That is the question you need to answer: "When I am to spawn an enemy, what type of enemy should I spawn?" But don't answer it here; answer it in your game, in code.

But this doesn't make sense:



Creation code/create events don't happen until after an instance is created. So creation code of the enemy instance can't possibly tell a spawner how to create the enemy that contains the code. The problem is that I can't understand what you're saying. Your autotranslator is not working very well. If you're trying to create a generic spawner object that you can place in the game many times, and each instance of that object spawns a single type of enemy, then use Variable Definitions. That is literally what they're for. If you want to have one instance of an enemy spawner object that spawns whatever type of enemy the situation calls for, then it's possible, but not simple. You'll have to find a way to tell the spawner, at a given time, to spawn a particular enemy. That's something you will have to define, because it depends on your game.

There are several solutions to the tutorials on how to spawn an enemy, but the problem arises when a separate respawn object begins to spawn for each enemy. I have not found a solution that uses one object to spawn enemies
 

Nidoking

Member
This response is just more of what you were saying before, and doesn't clearly answer the questions I've asked. Be clear: Which do you want?
  1. A single object defined in the game, with a separate instance of that object for each enemy type you want to spawn
  2. A single instance of one object that spawns all enemy types
 

Imiglikos

Member
This response is just more of what you were saying before, and doesn't clearly answer the questions I've asked. Be clear: Which do you want?
  1. A single object defined in the game, with a separate instance of that object for each enemy type you want to spawn
  2. A single instance of one object that spawns all enemy types

ok

1.A single object defined in the game, with a separate instance of that object for each enemy type you want to spawn
 

Nidoking

Member
That's the simple way. All you need to do is choose a variable that will tell the spawner what type of enemy to spawn. In the code example, that might be "obj", but you might prefer "object_to_spawn" or "enemy_to_spawn" or something like that. Then you define that variable for each instance. I don't know whether the version of Game Maker you're using has Variable Definitions in the room editor. If it does, you can use that to define the variable. If not, you'll need to use creation code for each spawner. Then spawn whatever object type is defined in the variable.
 

Imiglikos

Member
That's the simple way. All you need to do is choose a variable that will tell the spawner what type of enemy to spawn. In the code example, that might be "obj", but you might prefer "object_to_spawn" or "enemy_to_spawn" or something like that. Then you define that variable for each instance. I don't know whether the version of Game Maker you're using has Variable Definitions in the room editor. If it does, you can use that to define the variable. If not, you'll need to use creation code for each spawner. Then spawn whatever object type is defined in the variable.
That is, the solution of a colleague Gamebot is suitable for this task?
do I need to use a parent then? and this script?

Can I you ask for a specific example of how it should look like?

Thank you
 

Nidoking

Member
You don't need parents. You don't need a script. And if you have to ask for an example of how to set a variable and use the value of that variable, then maybe making games is too difficult for you. Setting a variable is the simplest single thing you can do. You put the variable name, then an equals sign (=), then the value you want to assign to it. Then you put the same variable name where you want to use that value.

But I'm feeling generous today. I will give you the example. I'm going to call the variable object_to_spawn. You set it like so: object_to_spawn = enemy_type; Obviously, instead of "enemy_type", you put the name of the enemy object type. Then, when you do your instance_create call, instead of specifying an object type by name, you put object_to_spawn for the object type. Now, whatever type you put in the creation code will be the type it will spawn.
 

Imiglikos

Member
This solution is ok if it wants to spawn enemies, but for me the respawn is supposed to work when the enemy dies and, as I have in the code, it will respawn in 90 seconds.
I have many objects with the same spawn code for every enemy. It makes no sense to create a respawn object for every enemy. The problem here is that there should be a universal object that would give me respawn after the death of every selected enemy
 

Nidoking

Member
Okay, so when an enemy dies, you instance_create an enemy spawner and set its enemy_type to whatever the type of the enemy that died was. The spawner can sit for 90 seconds, spawn the enemy, and then destroy itself.
 

Imiglikos

Member
Yes I create generator instances .. and I have many for each individual enemy, and I would like there to be one generator instance .. can it be done?
 

Nidoking

Member
Then you'll need to create some kind of queue that keeps track of what enemies it needs to spawn and at what locations and times.
 

Imiglikos

Member
I Refresh the topic.

I have many enemies in the game and I have created an object for each of them separately so that each enemy can respawn after death. Is there a way for me to have only one object to respawn enemies? instead of creating dozens of objects?
Thank you in advance for helping everyone.

currently the code looks like this

obj_enemy

create

GML:
dead=false;
step

GML:
if hp <= 0 {
 
 
 instance_destroy();
 
 dead=true;
 

  with instance_create(x,y,obj_entity_die)
 
 
  {
  sprite_index = spr_enemy_die;
  image_speed=1;
  image_xscale = other.image_xscale;
  image_yscale = other.image_yscale;
 
 
  audio_play_sound(snd_enemy_die, 1, false);
 
   }
}


// respawn enemy
if (dead == true)
{
 
 
 instance_create(x,y,obj_respawn_enemy);
}
obj_respawn_enemy

create

GML:
alarm[0]=20*room_speed
dead = false
Alarm[0]

GML:
instance_create(x,y,obj_enemy)
step

GML:
if (dead = true)
{
alarm[0] = 90
dead = false
}
 

Simon Gust

Member
you can transfer object_index to keep track of what object and enemy was
GML:
var inst = instance_create(x, y, obj_respawn_enemy);
  inst.object_to_respawn = object_index;
and then use object_to_respawn in the alarm[0].
 

Imiglikos

Member
you can transfer object_index to keep track of what object and enemy was
GML:
var inst = instance_create(x, y, obj_respawn_enemy);
  inst.object_to_respawn = object_index;
and then use object_to_respawn in the alarm[0].

The alarm [0] in obj_respawn_enemy specifically indicates which enemy is to respawn. How does this work so that I can only use one object to resurrect any enemy? because currently I have a dozen objects obj_respawn_enemy obj_respawn_enemy1 obj_respawn_enemy2 obj_respawn_enemy3 obj_respawn_enemy4 obj_respawn_enemy5 obj_respawn_enemy6 obj_respawn_enemy7 etc...
 

Simon Gust

Member
The alarm [0] in obj_respawn_enemy specifically indicates which enemy is to respawn. How does this work so that I can only use one object to resurrect any enemy? because currently I have a dozen objects obj_respawn_enemy obj_respawn_enemy1 obj_respawn_enemy2 obj_respawn_enemy3 obj_respawn_enemy4 obj_respawn_enemy5 obj_respawn_enemy6 obj_respawn_enemy7 etc...
by deleting all of them except obj_respawn_enemy. It respawns the object transfered by the variable object_to_respawn.
 

Imiglikos

Member
by deleting all of them except obj_respawn_enemy. It respawns the object transfered by the variable object_to_respawn.
Hmmmm..something like that?

obj_enemy

step

GML:
if hp <= 0 {


instance_destroy();

dead=true;


  with instance_create(x,y,obj_entity_die)


  {
  sprite_index = spr_enemy_die;
  image_speed=1;
  image_xscale = other.image_xscale;
  image_yscale = other.image_yscale;


  audio_play_sound(snd_enemy_die, 1, false);

   }
}

// respawn enemy
if (dead == true)
{


var inst = instance_create(x, y, obj_respawn_enemy);
inst.object_to_respawn = obj_enemy;
 
}

obj_respawn_enemy

Alarm[0]

GML:
object_to_respawn = object_index;
 
Last edited:

Simon Gust

Member
ok, one more time in detail.

objects have a built-in variable called "object_index", it refers to the object they are. For example, the object_index of obj_enemy_turret_boss_5000_red_variant is obj_enemy_turret_boss_5000_red_variant, not their parent and not any other object.

If every enemy instance has this information on their hands, you should be able to tell obj_respawn_enemy which object to respawn.
Using dot-operation you can transfer information from one object to the other (inst.object_to_respawn = object_index). object_to_respawn is now owned by the new instance of obj_respawn_enemy.
Both the variable ("object_to_respawn") of the newly created obj_respawn_enemy and the object_index of the enemy that died hold the same value.

what comes here?
Alarm[0]
GML:
instance_create(x, y, <insert your answer here> );
 

Imiglikos

Member
ok, one more time in detail.

objects have a built-in variable called "object_index", it refers to the object they are. For example, the object_index of obj_enemy_turret_boss_5000_red_variant is obj_enemy_turret_boss_5000_red_variant, not their parent and not any other object.

If every enemy instance has this information on their hands, you should be able to tell obj_respawn_enemy which object to respawn.
Using dot-operation you can transfer information from one object to the other (inst.object_to_respawn = object_index). object_to_respawn is now owned by the new instance of obj_respawn_enemy.
Both the variable ("object_to_respawn") of the newly created obj_respawn_enemy and the object_index of the enemy that died hold the same value.

what comes here?
Alarm[0]
GML:
instance_create(x, y, <insert your answer here> );
Thank you very much for your help .. your solution works ;-) I don't have to create separate instances for the respawn of enemies and thanks for the clarification.
I have one more question. In the alarm I have a set time of 90 seconds after which enemies have to respawn, but they will respawn after several seconds. What could be the problem?

obj_respawn_enemy

create

GML:
alarm[0]=20*room_speed
dead = false
step


GML:
if (dead = true)
{
alarm[0] = 90
dead = false
}
Alarm[0]

GML:
instance_create(x, y,object_to_respawn);
 

Simon Gust

Member
the timer for alarms doesn't count down 1 per second, it counts down room_speed per second. If your game runs at 60 fps (room_speed = 60), then an alarm set to 90 will set off after 1.5 seconds.
Besides that, I don't think your step event does anything because I don't see "dead" being set to true anywhere in your code.
You don't actually need the step event at all, you can set alarm[0] to 90 * room_speed in the create event.
Something I would add though is an instance_destroy() in the alarm, so that the respawn object does not eat away your performance after it has resurrected the enemy.
 

Imiglikos

Member
the timer for alarms doesn't count down 1 per second, it counts down room_speed per second. If your game runs at 60 fps (room_speed = 60), then an alarm set to 90 will set off after 1.5 seconds.
Besides that, I don't think your step event does anything because I don't see "dead" being set to true anywhere in your code.
You don't actually need the step event at all, you can set alarm[0] to 90 * room_speed in the create event.
Something I would add though is an instance_destroy() in the alarm, so that the respawn object does not eat away your performance after it has resurrected the enemy.

ok

Alamr[0]

GML:
instance_create(x, y,object_to_respawn);
instance_destroy(object_to_respawn);
Simon Gust Thank you again for your help and for explaining the whole issue.
 
Last edited:

Simon Gust

Member
ok

Alamr[0]

GML:
instance_create(x, y,object_to_respawn);
instance_destroy(object_to_respawn);
no, don't destroy the object you want to respawn.
Destroy the object that is respawning the enemy (aka itself).

To destroy the calling instance, instance_destroy() can be left without arguments.
 

Imiglikos

Member
no, don't destroy the object you want to respawn.
Destroy the object that is respawning the enemy (aka itself).

To destroy the calling instance, instance_destroy() can be left without arguments.
right ... I destroyed the instance I created thanks for your attention


GML:
instance_create(x, y,object_to_respawn);
instance_destroy();
 
Top