How do I undo destroy

0 favourites
  • 5 posts
  • So here's the problem.

    Whenever X hits Player > Player destroy and restart layout. Thing is I have Player set outside the layout because I want to do a set player at X,Y at the start of the layout.

    Problem comes when you die, player gets destroyed so when the layout is reseted, there's no player to set at X,Y. How do I solve this? I am guessing is just an easy trick but I am still a noob in this.

    Thank you

  • Place the Player outside the Layout and do --->>> System: At Start of Layout -> Subevent: System -> Trigger once while True -> In the Subevent: Create Player at Layout (0 - 1 - 2...) Position : X/Y

    Or you can do (if you want to use Checkpoints or Lives):

    If Player is destroyed ->System -> Trigger once while True-> System set Variables to 0 - 1 - 2 - 3 ..... (for every Variable which is important for your Gamedesign (Lives - Points - etc.)) -> Create Player at Layout (0 - 1 - 2...) - Position X/Y

    if you have a Ceckpoint then do another Subevent and say: If Variable "Checkpoint" is 1 - 2 - 3... then create Player at Position ......

    You have to use "System -> Create Player to" not "Player -> Set Position to"

    The reason because you have to do this steps is: If your Player is destroyed, then the Player is destroyed and can not placed anymore. Only a System "Create" command can bring back your Player on the Screen.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm not sure what you have going on exactly with your events, but you could just set the player to invisible (instead of destroying) and set an instance variable on it to keep track of if the player is "dead" or not. That way you could disable things happening to them, it would look identical, and you could still do whatever you want to the player object since it still exists.

  • That's not doing the trick for me. Either I am doing something wrong or you forgot to tell me something. If you have the player outside the layout and you create one, you will have two players. the new one you created just doesn't obey commands, just stands stills, and the other one, well is outside the layout.

    Thanks for your help tho

  • I kinda fix it doing something different. I let you know what I've done and you guys tell me if that sounds right to you or it could bug out.

    So I have a square for a player as invisible and an image pinned to it. So this is what I did.

    When health is less or equal to 0 I set invisible my UI (score, lifes, etc) and destroy the image pinned to the player so the player stills alive. Wait 0.5 and restart layout.

    Then I do On start of the layout set UI objects to visible. Pin image to player at position & angle.

    Subevent trigger once: reset global variables to default (so you get score to 0 and full HP) & player set position to 50,500.

    So far with these little amount of events is doing exactly what I wanted. Now I dont know if that would cause trouble, I guess I will know in the future. I did this because the tips you gave me didn't work.

    Would like to hear some feedback. Thanks

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)