How to link health bar actor to self attribute health of enemy?
i have made my enemies have personalised health now, they have 5 hitpoints each, using a self attribute. ive made real attributes and constrained the health bar to it so now every spawned enemy has their own health bar also, however, i cant figure out how to make rules to make the health bar respond to actions triggered by a self attribute.
e.g. i want:
self health = 5 spawn actor health bar (full)
self health = 4 spawn actor health bar (3/4)
i tried this and it isnt working, i think because the full bar stays on top and blocks visibility of the 3/4 bar, 2/4 bar etc. so i made a rule saying if health bar (full) collides with health bar (3/4), destroy the full one, but it doesnt work for some reason.
basically just need to know, how can i make enemie's personalised health bars, gradually decrease as their self.heath decreases in value.
thanks again in advance guys
e.g. i want:
self health = 5 spawn actor health bar (full)
self health = 4 spawn actor health bar (3/4)
i tried this and it isnt working, i think because the full bar stays on top and blocks visibility of the 3/4 bar, 2/4 bar etc. so i made a rule saying if health bar (full) collides with health bar (3/4), destroy the full one, but it doesnt work for some reason.
basically just need to know, how can i make enemie's personalised health bars, gradually decrease as their self.heath decreases in value.
thanks again in advance guys

Comments
Take a look at tshirtsboots cookbook:
There you can learn how to constrain an actor to a number so you don't have to ad rules in the healthbar actor.
Lump Apps and My Assets
watched the tutorial you linked but didnt seem relevant.
i need to trigger an action that will alter the health bar, in accordance to the self attribute of the enemy's health.
basically what im asking you is, how can you make a rule, that changes an actor when the value of a self attribute changes.
e.g.
(enemy actor) self.health = 5
(health bar actor) = full
--enemy is hit with bullet--
(enemy actor) self.health = 4
(health bar actor) reduces in size to 75% health
tshirtbooth i watched the video, but its not relevant to me, i cant link the health bar to a game attribute because it needs to be personalised within each enemy.
i have 1 enemy. and a random spawner that spawns multiple instances of this enemy.
i have a set a self attribute on this enemy of self.health to value of 5. so every spawned instance of this enemy, have its own health, which is 5.
i have made two game attributes, and constrained them to the enemy, so i can then constrain the health bar to the enemy, so now every enemy have its own health bar.
HERES the problem, i dont know how to link the health bar, to a SELF ATTRIBUTE. i cant make a GAME ATTRIBUTE because when the value reaches 0, so the enemy dies, ALL enemies will die. i need it to be personalised, so only that 1 enemy that is killed, dies, not EVERY instance of the enemy.
hopefully now you guys understand my problem. how do i make multiple instances of a single enemy, have its own personalised health bar, that decreases in value as the self.health attribute decreases?
thanks guys
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you need a separate bar actor I would not spawn the bad guys. I would have the total possible number of bad guys in the scene but out of view until activated.
Here's how I would code it.
in the bad guy prototype create a self attribute (integer) self.uniqueID
drag the number of instances in that you need (drag them out of the view)
go into each one and change each one's self.uniqueID value to a unique number (say 0, 1, 2, etc.)
Then you have a rule in the prototype that says when self.time > self.UniqueID*10 (or some other number - the smaller the faster the "spawning")
----put all your bad guy rules for movement within this rule
OK now the health bar stuff. You will need to drag the same number of health bars into the scene as bad guys. I would recommend renaming each bar and bad guy in the layer panel. Then you will need to unlock each bad guy instance and have a rule like this.
When overlaps with bullet
change attribute currentscene-->layer-->background-->healthbar1-->width to width-5 (or whatever value you want)
You'll need to do this for every bad guy.
Then you'll need to unlock every health bar and do this
constrain attribute self.positionX to currentscene-->layer-->background-->badguy1-->positionX
constrain attribute self.positionY to currentscene-->layer-->background-->badguy1-->positionY
You will really need to test this to see how the constrains effect performance.