1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Projectile collision destroy instance error

Discussion in 'Programming' started by Stamos22, Mar 8, 2019.

  1. Stamos22

    Stamos22 Member

    Joined:
    Aug 11, 2017
    Posts:
    9
    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.
     
  2. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,071
    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.
     
  3. Stamos22

    Stamos22 Member

    Joined:
    Aug 11, 2017
    Posts:
    9
    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
     
  4. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,071
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice