Need help with healthbar

1 favourites
  • 13 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I added a healthbar into my 3d game, but I can't figure out how to make it where the layout restarts, or the player respawns at the start of the layout. Also, when I go on a platform above or below the enemy thing that's trying to kill me, and it goes right above or below me, it still takes some of my health off. If anyone can figure out anything I just said, I'd appreciate them replying. Thanks!

  • If you restart the layout when health is 0 then player should be back in its initial position unless you set the player to global. I'm not sure about the under/over platforms in 3D but maybe you are touching the collision box so you need to make either the platform or player collision box smaller, or it could be something more complex being that its 3D I don't know I can't see the game and am only guessing with this.

  • The thing is, I have a healthbar where it has four animations of it getting smaller, if you can understand that. I have never actually been able to figure out how to do the healthbar at all, so if you have any ideas, I would appreciate them.

  • Also I'm using the free version and can't use alot of events.

  • The thing is, I have a healthbar where it has four animations of it getting smaller, if you can understand that. I have never actually been able to figure out how to do the healthbar at all, so if you have any ideas, I would appreciate them.

    You can set the animation frame based on health value using events

  • I tried it, but it still doesn't work. Here's what all my events for the healtbar look like:

    Event: Player: on collision with enemy

    Subevent: Healthbar: Animation frame<4 Action: Healthbar:set animation frame to Healthbar.Animationframe+1 Action: System: subtract 1 from Health

    Event: System: Health = 0 Action: Restart layout.

    I don't know if you'll be able to understand that or not. And the Health thing is my global variable. Thanks.

  • yeah i was also looking for it

  • Health bar set frame int(health/10) 100 is full health. Divided by 10 assumes health bar has 10 animation frames 0 being low health, 10 being full health

    If your health bar has 20 frames for finer resolution then divide health by 5 ( not 20 )

    I think I got this right off the top of my head, but I usually use this kind of system

    You could also set width of the health bar to value of health so it will shrink from 100 to 0. In this case just make sure the origin point is set to left not center

  • I tried it, but it still doesn't work. Here's what all my events for the healtbar look like:

    Event: Player: on collision with enemy

    Subevent: Healthbar: Animation frame<4 Action: Healthbar:set animation frame to Healthbar.Animationframe+1 Action: System: subtract 1 from Health

    Event: System: Health = 0 Action: Restart layout.

    I don't know if you'll be able to understand that or not. And the Health thing is my global variable. Thanks.

    Let's say you have 5 frames and 5 health, the basics would be to set animation frame to health, because they are same frame 5 is full health (5) for example.

    If it's more a percentage or other values, you create events to set animation frame based on the amount of health you have. On collision with enemy you can subtract from health, but you don't need to put the animation health bar events also in there, they should be separated out so it's easy to understand, for example if health > 80 then set health bar animation frame to 5.

  • Okay, so I got the healthbar to deplete when I run into the enemy guy, but the thing I can't figure out is, how do I get the player to respawn at the beginning of the level after being hit three times? Oh, yeah, anyone want to play my other game? It's called Downfall. Thanks!

  • Okay, so I've figured some more stuff out, so now all I need to do is make the player respawn at the start of the level, rather than where he was when he died.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • On health 0 : player set position to x,y

  • The thing is, I'm a free user and can't use alot of events.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)