How do I undo destroy

Get help using Construct 2

Post » Sun Jul 26, 2015 10:53 pm

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
B
14
S
5
Posts: 252
Reputation: 1,713

Post » Sun Jul 26, 2015 10:58 pm

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.
Last edited by Edelplastic on Sun Jul 26, 2015 11:25 pm, edited 13 times in total.
B
8
S
2
Posts: 53
Reputation: 687

Post » Sun Jul 26, 2015 11:00 pm

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.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Mon Jul 27, 2015 11:44 am

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
B
14
S
5
Posts: 252
Reputation: 1,713

Post » Mon Jul 27, 2015 12:43 pm

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
B
14
S
5
Posts: 252
Reputation: 1,713


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 8 guests