bullet bounce sfx
This commit is contained in:
parent
23d2a439c4
commit
99bc1cac0c
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue