How to add custom health bars for different enemies?

Get help using Construct 2

Post » Mon Jul 27, 2015 7:34 pm

Hi, Im making a "Shoot 'Em All" game, and I want to know if there is anyway to create a custom health bar for each enemy, with this I mean, all the enemies are the same sprite, with the same conditions, so they're cloned, I know how to make a health bar to ONE of them, but I want to know if its possible to make the health bar individually for each enemy, because the other day, I was testing, and the health bars only worked for one of them.
B
4
S
1
Posts: 20
Reputation: 388

Post » Tue Jul 28, 2015 10:20 pm

I'm guessing that the issue is that either
1. the health variable that the health meter displays is a global variable instead of an instance variable on the monster sprite or
2. the logic for rendering the health meter is calling just a single instance instead of each instance - in this case adding System.For Each as a sub-event and selecting the monsters and applying the health meter logic to it might help.
B
8
S
2
Posts: 21
Reputation: 509

Post » Wed Jul 29, 2015 8:11 am

Have a look at containers..

If you put the healthbar in a container with your enemy it will be linked to the enemy..
this way if you set the healthbar to enemy.health it will only do it for the linked enemy..

Another way would be to link both objects using UID..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Aug 03, 2015 7:51 pm

I know what you are talking about, but the problem is, whenever I hit one of the enemies, ALL the health bars goes down, but if I hit another one, it doesnt, thats the problem Im having
B
4
S
1
Posts: 20
Reputation: 388

Post » Mon Aug 03, 2015 8:07 pm

If you are using either the uid method or the container method this shouldn't be happening if you have your events set up properly..

I don't think that without seeing your events and/or capx we can help any further..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Aug 03, 2015 9:59 pm

Lemme take a shot at this. You may have it like this:

Code: Select all
Bullet on collision to enemy
-- subtract bullet damage from hp


when it should be something like this:

Code: Select all
Enemy on collision with bullet
-- subtract bullet damage from hp


then, display the health bar. That way each monster calculates its own damage one bullet at a time, and not one bullet calculates all the damage to all enemies.

I'll try the separate hp bars and see if I can get that working. Will post it if I come up with something.
B
5
S
1
Posts: 23
Reputation: 426


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 39 guests