This commit is contained in:
kimrdd 2024-04-21 03:23:00 +02:00
commit d60ab75afb
1 changed files with 5 additions and 0 deletions

View File

@ -1,5 +1,6 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Assertions; using UnityEngine.Assertions;
using UnityEngine.Events;
[RequireComponent(typeof(Collider))] [RequireComponent(typeof(Collider))]
public class Projectile : MonoBehaviour public class Projectile : MonoBehaviour
@ -19,6 +20,8 @@ public class Projectile : MonoBehaviour
public HealthComponent comingFrom; public HealthComponent comingFrom;
public UnityEvent OnReflect;
private Vector3 prevVel; private Vector3 prevVel;
private void Awake() private void Awake()
@ -59,6 +62,8 @@ public class Projectile : MonoBehaviour
} }
Vector3 newVel = Vector3.Reflect(prevVel.normalized, collision.contacts[0].normal.normalized); Vector3 newVel = Vector3.Reflect(prevVel.normalized, collision.contacts[0].normal.normalized);
body.velocity = newVel.normalized * prevVel.magnitude * bounciness; body.velocity = newVel.normalized * prevVel.magnitude * bounciness;
OnReflect?.Invoke();
AudioManager.PlaySound("BulletBounce", transform.position);
} }
} }
} }