Counter that counts deaths
I want to add to a counter every time a player dies so I have a finite number of lives. However my counter resets to 0 every time my player respawns. I have tried it in the puppet brain and in a microchip outside the puppet. To test the lives I have suicide button. This what I have
Controller sensor R1 wired to counter +
Counter wired to NOT gate by counter full (3 max)
R1 and NOT gate wired to AND gate wired to die in the controller sensor of puppet
I also have a counter for debug purposes that shows the counter going to 1 and then 0 when the player respawns.
Without the death part the counter does go up to 3.
-
Check out the Variable and Variable Modifier gadgets under Gadgets > Logic and Processing. They're all the way on the right side.
If you put a Variable gadget outside of your puppet, it will keep the value even if the puppet is destroyed/respawned. Then place the Variable Modifier on your puppet, make it target whatever name you gave the Variable, and have it increment the variable value by 1. -
If you want the lives to work across scenes then
1) put a variable in each scene called eg 'Lives' set it to 'persist' but don't give it a value.
2) add a variable modifier to set 'Lives' to 3 or whatever in your first level.
3) every time you have a 'death' event you need to have logic to calculate what to do - I send mine through a wireless transmitter so I can have my logic in one location.
3) so a 'dead' event I use a variable modifier to -1 from 'Lives', the 'dead' event also goes to the 'respawn' input on the controller gadget to respawn the user because they just lost a life.
4) I have a variable modifier set to 'get' the value of 'Lives'. The output feeds into a calculator input A. I compare if it is equal to 0 in input B. So while you have 1/2/3 lives the output will not do anything. When you lose your last life, the calculator will send a pulse.
5) you plug that pulse into the exit doorway of your scene to end the game (or to a game over screen).
Please sign in to leave a comment.