how do l make a actor destroy it's self when it's life bar runs out?

Anyone, if you wouldn't mind helping me, I would appreciate it if you could. I need to know how to destroy my actor when it's life bar run's out. I've just started so, please don't make it to complicated.

Thank you. :)

Answers

  • jsorr2jsorr2 Member Posts: 279

    Create an attribute (integer) in the scene called life bar and put a number into it that is equal to the amount of life.
    When your character gets hit, make a rule inside your actor.
    if actor overlaps or collides with actor (e.g. bullet)
    change attribute game>life bar to game>lifebar-1
    create another rule inside actor:
    if attribute game>life bar = 0
    destroy actor

    hope this helps!

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    I have a couple tutorials about creating and displaying health bars if you want to check them out:

  • nblsoccernblsoccer Member Posts: 8

    I'm sorry, I'm an idiot. I don't understand anything anybody said. Thank though. :'(

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Let's take @jsorr2's advice, which is good and break it down a bit to see if that helps:

    Create an attribute (integer) in the scene called life bar and put a number into it that is equal to the amount of life.

    Are you able to create an integer attribute called game.lifeBar with a starting value of... say 3?

    make a rule inside your actor. if actor overlaps or collides with actor (e.g. bullet)

    This is just so that there is a reason for the life decreasing. Are you able to create a new rule with the condition set to actor "overlaps or collides with" and then select another actor such as a bullet for it to collide with?

    change attribute game>life bar to game>lifebar-1

    Inside of that new rule, add a Change Attribute behavior and select game.lifeBar on the left side of the behavior and then -- using the 'e' expression editor button -- select game.lifeBar and type "-1" after it to subtract one from that attribute. Are you able to do that?

    create another rule inside actor: if attribute game>life bar = 0 destroy actor

    Are you able to create another new rule with the condition set to attribute game.lifeBar=0? And can you add a Destroy Actor behavior to that rule and set the actor name to the actor itself?

    If you let us know where you're having problems, we can help you get past that spot.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • nblsoccernblsoccer Member Posts: 8

    thank you so much tatiang. I needed so much help doing this.

    thank you. :D

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You're very welcome!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • nblsoccernblsoccer Member Posts: 8

    that helped me so much.

Sign In or Register to comment.