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

0 favourites
  • 5 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • 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!

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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)?

  • 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.

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

    Thanks for all the help!

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