Skip to content
Snippets Groups Projects
Commit 5fc9a5e4 authored by Robin Halseth Sandvik's avatar Robin Halseth Sandvik
Browse files

Added sound effects to basic attack.

parent b550d4fd
No related branches found
No related tags found
1 merge request!60Upgrades people.
......@@ -15,6 +15,7 @@ namespace BigSock {
public class BasicProjectile1 : BaseAttack {
//protected static readonly GameObject PROJECTILE_BASE = new AttackMovement();
public const string PROJECTILE_NAME = "bullets/basicsquarebullet";
public const string AUDIO_PATH = "The Essential Retro Video Game Sound Effects Collection [512 sounds] By Juhani Junkala/Death Screams/Alien/sfx_deathscream_alien1";
public override ulong Id => 101;
......@@ -57,6 +58,18 @@ namespace BigSock {
bulletScript.Stats = attack;
bulletScript.Direction = (target.Value - (Vector2) actor.transform.position).normalized;
// Play sound effect
var source = actor.source;
var audioClip = AudioService.SINGLETON.Get(AUDIO_PATH);
if (source != null && audioClip != null) {
source.clip = audioClip;
source.Play();
} else {
if(source == null) Debug.Log($"[BasicProjectile1.Activate()] audio source was null.");
if(audioClip == null) Debug.Log($"[BasicProjectile1.Activate()] audio clip was null.");
}
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment