Question: health bar made out of 3 separate actors

ZwireZwire Member, PRO Posts: 182
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 Member Posts: 1,485

    @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 Member, PRO Posts: 182

    @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 Member Posts: 1,485

    @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 Member, PRO Posts: 182

    @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 Member Posts: 1,485

    @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 Member, PRO Posts: 182

    @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 Member Posts: 1,485
    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.