I cant get the correct lives taken of when in contact with bombs

I have the code set to subtract 1 from lives when in contact with the bomb but when it goes in contact instead of going from 3 (the intended starting lives) it subtracts from zero.

Hi, you need to add a “Trigger once”- condition, otherwise the lives are continuously subtracted as long as the collision lasts.

1 Like

i have done this but still won’t work i am not sure if i have set the lives correctly would you be able to tell me how to set lives to 3 so i can check i have done it correctly

Okay, it depends a little bit on how you set everything up. In the example below I have an object variable of player (hit) set to 5 at the beginning of the scene (and display that value). When player collides with obstacle (in your case bomb), 1 point is subtracted from the object variable. Because of the ‘Trigger once’ - condition the point is only subtracted once at collision and not constantly.

1 Like

i have added that now however i cannot display the score when i drag the text onto my game it just disappears when i enter preview

Could you post your events again?

1 Like

You change the text to player.VariableString(Lives) but you actually want to display Minion.VariableString(Lives).

1 Like

Thank you very much, :smile:

1 Like