how do i stop replicating?

APPertizingAPPertizing Member Posts: 12
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.

Answers

  • TesseractEngineTesseractEngine Member Posts: 180
    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.
  • APPertizingAPPertizing Member Posts: 12
    Thanks for the quick reply, I did try that but that doesnt seem to be working for me?
  • TesseractEngineTesseractEngine Member Posts: 180
    It should work, mate! I'd need to have a look at your project to root out why not.
  • AdventuregoatAdventuregoat Member Posts: 10
    edited October 2012
    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:
    Screen shot 2012 10 01 at 5 43 45 PM

    It might not be the best way, but I just did it for my game, and it's working. :)
  • AdventuregoatAdventuregoat Member Posts: 10
    Oh, durp... You would still need to utilize Tesseract's attribute to keep it from going over.

    So, in the collision with fish, you would just add a second rule that only adds fish if "game.lives" attribute is less than 6.

    Screen shot 2012 10 01 at 6 31 33 PM





    Now it is fully working and not going over by combining the two :)
Sign In or Register to comment.