1. Hey! Guest! The XXX GMC Jam will take place between August 24th, 12:00 UTC (Friday noon) and August 27th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

Windows [SOLVED] Reactivated object apparently doesn't exist despite getting a draw event.

Discussion in 'Programming' started by atrus159, Aug 9, 2018.

  1. atrus159

    atrus159 Member

    Joined:
    Aug 8, 2018
    Posts:
    26
    In my game I am adding a system where characters can enter a "downed" state upon taking too much damage. In this state they can get dragged around by other characters and eventually revived. To do this, I have the character make a char_downed object, give the char_downed their index, and then deactivate themselves.
    Then under certain conditions the char_downed will reactivate the index they have been given, reset position and health, and destroy them self. I want downed characters to be draggable between rooms, so I have the char_down reactivate their instance on room end and deactivate their instance on room start (characters are persistent).

    Right now, if a character is downed and then revived it works fine. If they are downed, dragged to another room and revived, they seemingly get up but will not respond to any kind of input including keyboard input. They still get a draw event and I can edit the draw event to confirm that it is still the right kind of character, but they don't get step events, keyboard events, or mouse events.

    To try to understand what was going on I put the following code in the character's draw event:

    Code:
    draw_text(x,y,instance_exists(self));
    draw_text(x,y+20,instance_exists(nicole_char));
    draw_text(x,y+40,object_index);
    draw_text(x,y+60,nicole_char);
    
    As expected, this draws 1, 1, 65, 65 under normal conditions. When the character is downed, dragged to another room, and revived, it draws 1, 0, 65, 65. I don't even understand how this is possible. Please advise.
     
  2. atrus159

    atrus159 Member

    Joined:
    Aug 8, 2018
    Posts:
    26
    [SOLVED]: When you reactivate an instance, It sometimes will not actually reactivate for a frame after you call the code. This means that if you try to reactivate an instance on the same frame that you call goto_room() it will still be deactivated for the room transition. I don't know how to explain the specific behavior of the object that I got but making it so it was reactivated a frame earlier fixed the problem.
     
    MarisFrance likes this.

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