[Code] Heartbeat sound when life is low


Big Thanks to Crusha K. Rool and 100GPing100 from UDK Forums.

Use this code in your custom Pawn class:

class MyNewPawn extends UTPawn;
var AudioComponent HealthSound;

event TakeDamage(int DamageAmount, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
{
    super.TakeDamage(DamageAmount, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);
    if (Health <= 25)
    {
        HealthSound.Play();
    }
}

function Tick(float DeltaTime)
{
    Super.Tick(DeltaTime);

    if (Health > 25)
         HealthSound.Stop();
}

simulated event Destroyed()
{
    HealthSound = None;
    super.Destroyed();
}

defaultproperties
{
    Begin Object class=AudioComponent name=MenuAudioComponent
        SoundCue = SoundCue'Sounds.Misc.Heartbeat_Cue' //Change this to your soundcue.
    End Object
    HealthSound = MenuAudioComponent
    Components.Add(MenuAudioComponent)
}
Advertisements

About Satheesh (aka ryanjon2040)

Genuine Unreal Engine user

Posted on May 22, 2012, in Tutorials and tagged , , , , , , , , . Bookmark the permalink. 1 Comment.

  1. Ahh, just like ChaosUT.
    Perfect. I always loved this in UT99 and 2K4 🙂

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: