• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Projectile collision destroy instance error

Stamos22

Member
Hello,

I recently have been following along with Heartbeasts' action rpg course. I've been working my through it and feel like I have learned a fair amount though I have recently encountered an error that I have been unable to fix.

I assumed since in the video he does not get an error that missed something in a previous lesson but I have now gone through the course twice trying to find my mistake to no avail.

The error message I get is from when a projectile collides with the player. I want the projectile to be destroyed on collision but when I put the collision event and the instance_destroy(); command, it causes a fatal error.

This is the error report.


___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Evento_stinger
for object o_player:

Unable to find any instance for object index '100070' name '<undefined>'
at gml_Script_hurtbox_entity_can_be_hit_by (line 3) - var _is_target = is_target(object_index, _hitbox.targets_);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_hurtbox_entity_can_be_hit_by (line 3)
called from - gml_Object_o_player_Collision_35004c3d_dfdc_4329_9b70_6631acd0b11f (line 3) - if hurtbox_entity_can_be_hit_by(other)



If I am reading this correctly then the object is getting destroyed before the code can finish?

Also, it only crashes when I try to destroy the object. I can have the projectile hit the player, do damage and keep going, but when I try to run the instance_destroy this error comes up, though it does not come up in the tutorial video.


Any help would be greatly appreciated.
 

samspade

Member
Probably need the actual code of your scripts. But it looks like you have a script called is_target and for whatever reason it doesn't like the use of object_index.
 

Stamos22

Member
Thanks for the quick reply!

This is the is_target script

///@arg value
///@arg target_array
var _value = argument0;
var _array = argument1;
var _array_length = array_length_1d(_array);

var _index = 0;
repeat _array_length
{
if _value == _array[_index] return true;
if object_is_ancestor(_value, _array[_index]) return true;
_index++;
}

return false;
---------------------------------------------------------------------------

and this is the hurtbox_entity_can_be_hit_by

///@arg hitbox
var _hitbox = argument0;
var _is_target = is_target(object_index, _hitbox.targets_);

return !invincible_ and _is_target
 

samspade

Member
Thanks for the quick reply!

This is the is_target script

///@arg value
///@arg target_array
var _value = argument0;
var _array = argument1;
var _array_length = array_length_1d(_array);

var _index = 0;
repeat _array_length
{
if _value == _array[_index] return true;
if object_is_ancestor(_value, _array[_index]) return true;
_index++;
}

return false;
---------------------------------------------------------------------------

and this is the hurtbox_entity_can_be_hit_by

///@arg hitbox
var _hitbox = argument0;
var _is_target = is_target(object_index, _hitbox.targets_);

return !invincible_ and _is_target
I'm not really certain. It seems like the error is from object_index not applying to anything but I don't know why that would be the case.

I would put a break point in the debugger and step through everything checking the values as you go.
 
Top