Moving Health Bar

I'm looking to have enemies with health bars floating above their heads to indicate how much is left to the player. The enemies will be moving around and will be taking damage both simultaneously and separately. There are going to be as many as 20-30 on screen at the same time...

I'm assuming they have to be a separate actor that mimics the movement of each enemy...

There are 2 problems with this I'm trying to figure out:
1. Is there a way to anchor the health bar to another actor?
2. Is there a way for me to reference the health of each separate enemy? Seems like global variable will be a complicated mess, especially with (non)simultaneous damage.

Just looking for some ideas on how to solve this problem.

Thanks!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I made a couple of demos:

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

  • SolarPepperStudiosSolarPepperStudios Member Posts: 754
    Yes there is a way to anchor the health bar to another actor but it would require editing the actor in the scene so they can access the scene attributes. You would do that by saying constrain health bar.position.x to enemy.position.x and do the same for y but add 10 (or any other appropriate number) to it so that it is above the actor's head.
  • paulchungpaulchung Member Posts: 10
    Sweet guys! Thanks! Not being able to access instance properties is a pain in the butt =P
Sign In or Register to comment.