GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Question: health bar made out of 3 separate actors

ZwireZwire Posts: 165Member, BASIC
edited April 2016 in Working with GS (PC)

Hi,

I know how to make a standard life bar with a health meter but I cant figure out how to make a life bar made out of 3 separate actors.
Whenever you get hit by an enemy you'll lose 1 actor (hart). When you get hit again you'll lose another hart and so on.

Does anybody know how?

Thanks.

Comments

  • IceboxIcebox Posts: 1,483Member

    @Zwire You can do this with 2 actors first create a game integer attribute Health set it to 3 ( 3 hearts)

    Create a heart actor make it transparent set its alpha to 0.4 or any number you prefer
    place a replicate behavior

    Create another heart actor same size place a replicate behavior in it but this time
    set the copies to game.health

    Place them on top of each other on the scene , the transparent heart on the back and the normal heart front.

    Thats it

  • ZwireZwire Posts: 165Member, BASIC

    @Icebox Thanks man!

    I did all the things you said. I now have 3 transparent hearts in the back and in front 3 normal hearts.

    How can I destroy a heart when player collides with an enemy?

  • IceboxIcebox Posts: 1,483Member

    @Zwire in your Player actor place a rule

    if actor overlaps or collides with enemy
    change attribute game.health to game.health -1

    the health will change from 3 to 2 and you'll have 2 normal hearts but the 3 transparent hearts will remain the same and they will work as a background so that the player knows he lost a heart. if you don't want a transparent background you can delete it.

  • ZwireZwire Posts: 165Member, BASIC

    @Icebox It worked. Thanks a lot man!

    Theres one problem though. Whenever I preview the game all the hearts are there but when I die and all my hearts are gone, when I hit the refresh button to start a new game, the hearts dont reappear. Only when I go out of the preview screen and in again.

    Is this a bug?

  • IceboxIcebox Posts: 1,483Member

    @Zwire Did you make the refresh button, is it resetting the scene ? or do you mean GS refresh button that restarts the whole game?

    if you mean reset scene , just create an invisible actor that controls your game level attributes and put a a change attribute in it , Change attribute game.health to 3. This will trigger once at the start of each level.

    Game level attributes don't reset by their own when you reset or change the scene so you should always put that in mind. But if you mean your resetting the whole game from GS engine , i didnt have this problem before.

  • ZwireZwire Posts: 165Member, BASIC

    @Icebox I only have one scene. I think I mean the GS refresh button. Whenever I preview the game and after I die press this button:

    ...the hearts are gone and wont reappear.

  • IceboxIcebox Posts: 1,483Member
    edited April 2016

    @Zwire hey , i know this is an old thread but i remember when i read this on the 1.25 bugs fixes

    1499 - (Windows) Pressing reset button in native preview doesn’t reset game attributes

    Try it now with the new version it should work properly

Sign In or Register to comment.