Different Sounds for Different Damage Types

I would like the player to make different damage sounds depending on what ails him:

"Aargh!" for any death except drowning - working
"Ouch" for damage from weapons - working
"Oof" for damage from falls - working
"Glug" for death by drowning - working

But also

"Eeeh!" for damage from fire
"Splutter!" for damage from smoke inhalation

Now these last two have me quite stumped. The first four were simple manipulations of things in the standard abilities (+ swimming pack). I'm guessing I would need some additional custom abilities, 'Burn' and 'Choke'? Then I could use the same methods with state system to achieve the result I want, overriding the default damage sounds when damage is taken in those states? Or is there a simpler way that I've missed?

Thanks in advance for any advice
Anasta
 
Hmm, thanks for that, Andrew. I'd need a way to pass some extra information from the gameobject causing the injury to the health component to mark the damage type, wouldn't I? Could I add a tag to the gameobject and pull that info out? Not sure...

Here's where I am so far with a different approach:

I have a fire particle gameobject with a trigger and a variant of the DamageZone script (from the Demo) called 'BurnZone'. It's essentially the same. I want to switch on a state (Burning) on the character entering the trigger, deal the damage, then immediately switch the state off again. Using the state system, I can then simply have a preset that changes the taking damage sounds when the Burning state is on the character. The state should, if this works, only persist long enough for the character to get hurt and make the right sound. I think...

Code:
m_Health = health;
m_HealthTransform = health.transform;
//-- StateManager.SetState(?????, "Burning", true);
m_ScheduledDamageEvent = Scheduler.Schedule(m_InitialDamageDelay, Damage);
//-- StateManager.SetState(?????, "Burning", false);

This is the code that deals the damage, with two commented-out additions. The script works fine and deals damage the way it should when my two lines are commented out, but of course the character never obtains the Burning state so the desired sounds don't play. The question is, what do I replace the ????? with to set the state of the character?

It's been a long Opsive weekend, but I'm loving it!
Anasta
 
Solved it. I needed to add the StateTrigger script to my fire, which does the job just fine. Didn't know that script existed!

So, for anyone else interested - Here's how to have a character make different damage sounds on entering a trigger zone, the sound reverting to normal when he/she leaves the zone:

  • Add the DamageZone script to the trigger and configure however you want it.
  • Add the StateTrigger script to the trigger and have it invoke a new state to add to the character when in the trigger zone. Set the duration to -1 if you want the state to persist as long as the character remains in the trigger zone.
  • Add a new preset to the Health component to override the sounds when the state is set.

Happy days. Thanks Andrew and Justin. The support here is simply amazing, and you manage to point in the right directions just enough for me to feel a sense of accomplishment rather than feeling a bit stupid!

Anasta
 
Top