Super Knight : Enter the Dungeon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BombEffect : MonoBehaviour
{
public Rigidbody rigi;
//private void OnCollisionEnter(Collision collision)
//{
// if (collision.gameObject.CompareTag("Bomb") || collision.gameObject.CompareTag("DropItem"))
// {
// Debug.LogWarning($"OnTriggerEnter : {collision.gameObject.name} -> {gameObject.name}");
// if (KNOCKBACK)
// KnockBack(-(collision.transform.position - transform.position).normalized);
// else if (DESTROY)
// Destroy();
// }
//}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Bomb") || other.gameObject.CompareTag("DropItem"))
{
//Debug.LogWarning($"OnTriggerEnter : {other.gameObject.name} -> {gameObject.name}");
if (KNOCKBACK)
KnockBack(-(other.transform.position - transform.position).normalized);
else if (DESTROY)
Destroy();
}
}
[Space(5)]
public bool KNOCKBACK = false;
public float knockBack = 0.5f;
void KnockBack(Vector3 dir)
{
dir.y = 0;
rigi.velocity = dir * knockBack;
}
[Space(10)]
public bool DESTROY = false;
public GameObject prefabDestroy;
void Destroy()
{
if(prefabDestroy != null)
EventManager.Instance.Invoke("PrefabCreate", new EventManager.ObjectCreate(prefabDestroy, null, Vector3.one, transform.position));
gameObject.SetActive(false);
}
}