[SOLVED]Breathing volume increases as player gets more tired

Updated on August 9, 2016 in [A] Audio
Share on Facebook0Tweet about this on Twitter0Share on Google+0Share on Reddit0
3 on August 9, 2016

Hello,

I have a “Stamina” variable that goes down as the player sprints. I also have a breathing sound effect for while he’s running, but I would like the volume of the breathing effect to increase as the players stamina goes down and the volume to decrease back to complete silence once he’s back to max stamina.

Any help is appreciated
Thanks!

  • Liked by
Reply
2 on August 9, 2016

You could calculate your volume value like this: 

volumne = 1 – stamina

Master
on August 9, 2016

Going on from PlayJames’ comment since a volume of 0 is completely off you’d probably want to divide it by the max amount of stamina.
So when you have a max stamina of 100 it would probably looking something like this:
volume = 1 – (stamina / 100);

on August 9, 2016

I got it working 100% as I wanted it too, thanks guys! I tried asking this on the unity forum but got no help :(

Anyways I used this:
volume = 1 – (stamina / maxStamina);

Thanks again!

Show more replies
  • Liked by
Reply
Cancel