J
JealousOfCrows
Guest
So in my last forum post I mentioned that I am basically making a list of objects that need to be deactivated rather than destroyed and then reactivated upon player death. The main purpose of this opposed to a room restart is to maintain certain surfaces in the room to show players where they have died etc...
So my problem here is that I tried doing this with a parent object that contains two objects as children. The code picks up the ids of one of the children, but not the other. It then throws this error.
In the step Event of the controller:
############################################################################################
FATAL ERROR in
action number 2
of Step Event0
for object oController:
Unable to find any instance for object index '100052' name '<undefined>'
at gml_Object_oController_StepNormalEvent_2 (line 35) - if (List[| i].Deactivated == true)
############################################################################################
If I change the code in the controller object room start event from:
to activate the specific object directly, it works:
Whats weird is in my testing I used a different object that was a child of the oParBreakable (oPoisonBarrel) to test and it worked fine. I have gone through and checked all the code and their is nothing different betweeen these two objects that would affect the id not getting picked up in the list. Obviously the fix is to just check each individual object quickly. But as I want this system to loop through all enemies in a room and save them to the list, this will quickly result in a ton of code and I would rather just do it for the master parent of all the enemies. Is this a bug? Have I done something wrong here? Please let me know if you think you know what may be the case!
Thanks for your time. Cheers.
EDIT: I removed the oPoisonBarrel from being a child to the oParBreakable object and it now works. However, when I add the oPoisonBarrel back into the child structure, the oPoisonBarrel no longer works....so it seems that its only getting the first child object. Anyone know why this is?
EDIT #2: Issue is SOLVED. Everything posted above actually works. After a bit of debugging it turns out my explosive barrel spawns an explosion object which actually destroys other breakable objects around it rather than deactivating them. This is why the error couldnt find an instance of the object! DERP. Thanks for helping guys! Really appreciate it!
So my problem here is that I tried doing this with a parent object that contains two objects as children. The code picks up the ids of one of the children, but not the other. It then throws this error.
In the step Event of the controller:
Code:
if (global.PlayerDeath == true)
{
if ds_exists(List, ds_type_list)
{
var dsLength = ds_list_size(List);
for (i = 0; i < dsLength; i++)
{
if (List[| i].Deactivated == true)
{
instance_activate_object(List[| i]);
List[| i].Deactivated = false;
}
}
}
}
FATAL ERROR in
action number 2
of Step Event0
for object oController:
Unable to find any instance for object index '100052' name '<undefined>'
at gml_Object_oController_StepNormalEvent_2 (line 35) - if (List[| i].Deactivated == true)
############################################################################################
If I change the code in the controller object room start event from:
Code:
if !ds_exists(List, ds_type_list) List = ds_list_create();
////This will crash
if instance_exists(oParBreakable)
{
with(oParBreakable)
{
ds_list_add(other.List, id);
}
}
Code:
if instance_exists(oExplosiveBarrel)
{
with(oExplosiveBarrel)
{
ds_list_add(other.List, id);
}
}
Thanks for your time. Cheers.
EDIT: I removed the oPoisonBarrel from being a child to the oParBreakable object and it now works. However, when I add the oPoisonBarrel back into the child structure, the oPoisonBarrel no longer works....so it seems that its only getting the first child object. Anyone know why this is?
EDIT #2: Issue is SOLVED. Everything posted above actually works. After a bit of debugging it turns out my explosive barrel spawns an explosion object which actually destroys other breakable objects around it rather than deactivating them. This is why the error couldnt find an instance of the object! DERP. Thanks for helping guys! Really appreciate it!
Last edited by a moderator: