29 lines
620 B
C#
29 lines
620 B
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using BITKit.Entities;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace BITKit
|
||
|
{
|
||
|
public class ImpactDamage : MonoBehaviour
|
||
|
{
|
||
|
public float damage;
|
||
|
private void OnCollisionEnter(Collision other)
|
||
|
{
|
||
|
if (!other.collider.TryGetComponent<EntityHitbox>(out var hitbox)) return;
|
||
|
var _damage = damage * other.impulse / Time.fixedDeltaTime;
|
||
|
// hitbox.entity.Invoke<DamageMessage>(new DamageMessage()
|
||
|
// {
|
||
|
// damage = (int)_damage.sqrMagnitude,
|
||
|
// target = hitbox.entity,
|
||
|
// });
|
||
|
}
|
||
|
|
||
|
private void OnCollisionExit(Collision other)
|
||
|
{
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|