How do I ignore 'Persist' behaviour on player death?

Get help using Construct 2

Post » Sun Dec 07, 2014 10:59 pm

Hello everyone!

Me and a group of other students are working on a platformer game using Construct 2 for an assignment, we came across one little problem however and that was the fact that the player could grind coins by replaying a level over and over again.

After a bit of searching we found out about the Presist behaviour which seemed to fix our issues at first, coins would not respawn on replaying the level.

However we soon discovered that they didn't even come back on a layout restart, meaning that if the player died and had to start that level over the coins would still be gone, which is something we don't want in our game.

How would we go about ignoring the Persist behaviour on objects whenever it's required?

To sum it up:

-Coins should not respawn on a level that the player already finished
-Coins SHOULD respawn when a player dies in a level
-On levels that players DID finish but didn't collect all the coins on they should be able to go back and get those coins, but on player death on that level only the coins the player didn't pick up before should respawn.

Thanks in advance!
B
3
Posts: 4
Reputation: 183

Post » Mon Dec 08, 2014 12:41 am

Simply let the player keep the coins they already collected when they die? - seems by far the easiest solution.

If not then one way could be to have the coins persistent, but never destroy the coins and only change their visibility. When the player touches a coin, simply test whether it is visible, if so collect it and turn it invisible, if it's not visible simply do nothing. When the player dies, set all the coins on the level that they died on to visible.
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

Post » Mon Dec 08, 2014 9:33 am

The visibility trick worked out perfectly, thanks!

Only one more question however:

On a Game Over we want all the levels and variables to reset. With variables that isn't a problem but considering the Persist function doesn't allow the coins to respawn even on a layout restart how would we make it so it completely resets the layout (and thus respawns the coins)?
B
3
Posts: 4
Reputation: 183

Post » Mon Dec 08, 2014 9:47 am

I haven't tried it, but r191 lets you reset persistent objects. Otherwise, you could have a System: Save from right at the start of the game, and just do a SystemLoad when you want a new game.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Dec 08, 2014 10:15 am

Saving and loading works perfectly, I can't believe I forgot to try that, haha.

Thanks for all the help!
B
3
Posts: 4
Reputation: 183


Return to How do I....?

Who is online

Users browsing this forum: sean080 and 21 guests