From 99bc1cac0c33542ee04e768906e854295a3fc62a Mon Sep 17 00:00:00 2001 From: Sveske Juice Date: Sun, 21 Apr 2024 03:22:20 +0200 Subject: [PATCH] bullet bounce sfx --- Assets/Scripts/Tower/Projectile.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assets/Scripts/Tower/Projectile.cs b/Assets/Scripts/Tower/Projectile.cs index 6157677..ed54230 100644 --- a/Assets/Scripts/Tower/Projectile.cs +++ b/Assets/Scripts/Tower/Projectile.cs @@ -1,5 +1,6 @@ using UnityEngine; using UnityEngine.Assertions; +using UnityEngine.Events; [RequireComponent(typeof(Collider))] public class Projectile : MonoBehaviour @@ -19,6 +20,8 @@ public class Projectile : MonoBehaviour public HealthComponent comingFrom; + public UnityEvent OnReflect; + private Vector3 prevVel; private void Awake() @@ -59,6 +62,8 @@ public class Projectile : MonoBehaviour } Vector3 newVel = Vector3.Reflect(prevVel.normalized, collision.contacts[0].normal.normalized); body.velocity = newVel.normalized * prevVel.magnitude * bounciness; + OnReflect?.Invoke(); + AudioManager.PlaySound("BulletBounce", transform.position); } } }