41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Invector;
|
|
using UnityEngine;
|
|
|
|
namespace Beyond
|
|
{
|
|
public class DeathCollider : MonoBehaviour
|
|
{
|
|
//vIHealthController
|
|
public bool m_destroyOtherObjects = true;
|
|
void Awake()
|
|
{
|
|
var collider = GetComponent<Collider>();
|
|
if (!collider)
|
|
{
|
|
Debug.LogError("DeathCollider: no collider found!");
|
|
return;
|
|
}
|
|
|
|
collider.isTrigger = true;
|
|
gameObject.layer = LayerMask.NameToLayer("Triggers");
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
var health = other.GetComponent<vIHealthController>();
|
|
if (health != null)
|
|
{
|
|
health.TakeDamage(new vDamage(10000000, true));
|
|
Debug.Log($"GameObject: {health.gameObject.name} was killed by DeathCollider {gameObject.name}");
|
|
}
|
|
else if (m_destroyOtherObjects)
|
|
{
|
|
Destroy(other.gameObject);
|
|
}
|
|
}
|
|
}
|
|
}
|