Added sound effects.

posted in: Weekly Progress | 0

In different scripts  sound effects are added.

 

 

public AudioClip PlayerHitSound1;
public AudioClip PlayerHitSound2;
public AudioClip PlayerHitSound3;

return;
PlaySoundEffect(true, false);

public void PlaySoundEffect(bool isHit, bool healthPick)
{
if(isHit)
{
int random = Random.Range(1, 4);
if(random == 1)
PlayerAudioSource.PlayOneShot(PlayerHitSound1);
else if(random == 2)
PlayerAudioSource.PlayOneShot(PlayerHitSound2);
else if(random == 3)
PlayerAudioSource.PlayOneShot(PlayerHitSound3);
}

if(healthPick)
{
PlayerAudioSource.PlayOneShot(PlayerHealthSound);
}
}

PlayerAudioSource.PlayOneShot(PlayerHitSound);

PlayerAudioSource.PlayOneShot(PlayerHealthSound);

 

Rope Script :

WeaponAudioSource.PlayOneShot(WeaponShootSound);

Shotgun script :

WeaponAudioSource.PlayOneShot(WeaponShootSound);

Rifle script :

WeaponAudioSource.PlayOneShot(WeaponShootSound);

Animals script :

public AudioClip AnimalSound1;
public AudioClip AnimalSound2;
public AudioClip AnimalSound3;

 

if(!AnimalSound1)
return;

int random = Random.Range(1, 4);
if(random == 1)
AnimalAudioSource.PlayOneShot(AnimalSound1);
else if(random == 2)
AnimalAudioSource.PlayOneShot(AnimalSound2);
else if(random == 3)
AnimalAudioSource.PlayOneShot(AnimalSound3);
}

 

Leave a Reply