43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using UnityEngine;
|
|
using Projectiles2D;
|
|
|
|
public class BasicProjectile : Projectile2D
|
|
{
|
|
protected override void OnHit(Collision2D target, Vector2 point, Vector2 relativeVelocity)
|
|
{
|
|
//var health = target.GetComponentInParent<Health>();
|
|
//if (health != null)
|
|
//{
|
|
// health.ApplyDamage(damage);
|
|
|
|
// if (knockback > 0f)
|
|
// {
|
|
// var targetRb = target.attachedRigidbody;
|
|
// if (targetRb != null)
|
|
// {
|
|
// var dir = relativeVelocity.sqrMagnitude > 0.0001f
|
|
// ? relativeVelocity.normalized
|
|
// : (Vector2)(target.transform.position - transform.position).normalized;
|
|
|
|
// targetRb.AddForce(dir * knockback, ForceMode2D.Impulse);
|
|
// }
|
|
// }
|
|
//}
|
|
var player = GameManager.Instance.PlayerObj;
|
|
|
|
if (target.collider.CompareTag("Player"))
|
|
player.GetComponent<PlayerController>().Die();
|
|
else if (target.collider.CompareTag("Projectile") || target.collider.CompareTag("Enemy"))
|
|
Despawn();
|
|
|
|
|
|
if (hitVfxPrefab != null)
|
|
{
|
|
Instantiate(hitVfxPrefab, point, Quaternion.identity);
|
|
}
|
|
if (hitSfx != null)
|
|
{
|
|
AudioSource.PlayClipAtPoint(hitSfx, point, sfxVolume);
|
|
}
|
|
}
|
|
} |