Collision and Heart Lives

Hi All!

I have a student who wants to create a game where the first person (camera) has “Heart Lives” (think Zelda). I am trying to help him code that when he collides with an item the item takes away one of his hearts. The hearts are attached to a 3D Text Item which is attached to the player (camera).

So far, we are able to get 1 heart to “delete” when a collision happens. What we can’t figure out is how we can end that process and start anew with “deleting” the second heart if a subsequent collision happens.

My thinking is we need another “IF” statement… something along the lines of “If Heart 1 is deleted then delete heart 2.” Maybe we need to create variables? Any help appreciated! Here’s where we are at:

Hi there, have you tried using a variable “hearts”,
See my screenshot here for code :slight_smile:

1 Like

Another possibility: deleting list elements
ACV-TRJ

1 Like

Awesome. This is what I was looking for! Thanks! I do notice that a collision will often take 2-3 of the hearts away. Any ideas on to limit it to just one heart? Maybe a “wait” code somewhere…

Yes, a tricky question. But if you change the variable for -0.5 (not for -1) on each collision, it might solve the problem.