how do i stop replicating?

I have a heart actor that is the health bar, whenever the main actors eats a fish he gets an extra heart. he starts with one and I would like it to go to 6 max hearts but they just keep replicating across the screen with the more fish he eats.I also have actors that will take away hearts when collided with but does anyone know how to stop replicating after a certain amount of replications?

Cheers.

0

Answers

You need a Game attribute to track the maximum number of hearts. Call it maxHearts, for example. Set it to 6. Now, in your behaviours that add a heart for eating a fish, add a Rule at the start saying When number of hearts is less than or equal to maxHearts.

You also might try this: Create a new integer attribute called lives in the "game attributes". Then, in your heart character, create six separate rules. Each rule checks to see what the Game attribute is. For example if game.lives =3 then replicate 3 times, and so on.

Of course, there would be another rule checking if your character was hit, and subtracting a heart at a time. It needs to look like this to work:

It might not be the best way, but I just did it for my game, and it's working.