Track health of a func_breakable

  • Site Migration: See bugs? Report them here. Want something changed or have an idea? Suggest it here.

HQDefault

...what
aa
Aug 6, 2014
1,057
Okay I initially used this thread to ask a different question, but I changed my mind on that, so now I'm asking this instead.

So my current project involves some pretty fancy use of func_breakables, to the extent that they are actually imperative to the gameplay. So I'd like to figure out a method of which I can track how much health it has so I can visually represent that somehow. I'm not certain if this is possible with a func_breakable, there may be an alternative, I might just be screwed. I dunno. Can I do this?
 
Last edited:

Idolon

a survivor with too much paint
aa
Feb 7, 2008
2,043
I can't think of any way to actually output a func_breakable's health or the amount of damage it takes. However, there are some alternatives I can think of:

1) Use a series of func_breakables that indicate stages of health. Instead of one object with 600 health, use three of them with 200 health each. Each stage reveals itself after the previous is destroyed, and there is some unique visual effect to indicate that it has been damaged. You'll have to experiment with the exact implementation of this, since you may run into issues with some of the damage being "eaten" when the final blow to one stage doesn't carry its damage over into the next stage.

2) Use a math_counter and tick it up/down by one every time the object is hurt, then kill the object when the counter hits its max/0. This method is easier, more reliable, and offers more granular feedback, but also makes all damage equal - a rocket and a pistol would do the same amount of "damage." You could potentially filter for different damage types and do some more nuanced work that way, but it would be tricky and maybe impossible to work how you want.

Hope this helps.

---

EDIT: Apparently func_breakable can just output a float percentage of its current health whenever it's damaged. Someone at Valve must've thought about this before.

Hook OnHealthChanged into a logic_compare's SetValueCompare, then set the logic_compare's Compare Value to a percent (50% = 0.5). Then use OnLessThan to trigger whatever events you'd like, such as a sound or particle effect. It's not a health bar, but it is feedback.
 
Last edited:

HQDefault

...what
aa
Aug 6, 2014
1,057
-snip-

Apparently func_breakable can just output a float percentage of its current health whenever it's damaged. Someone at Valve must've thought about this before.

Hook OnHealthChanged into a logic_compare's SetValueCompare, then set the logic_compare's Compare Value to a percent (50% = 0.5). Then use OnLessThan to trigger whatever events you'd like, such as a sound or particle effect. It's not a health bar, but it is feedback.

Well, I've gotten it to the point that I have this output, but I'm not sure what to put for the parameter override:
PCdaZvz.png

Or perhaps I'm not supposed to use outputs at all. Not sure.

EDIT: Nevermind, it appears I'm supposed to leave it blank