The script is attached to a GameObject a cylinder.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyAttack : MonoBehaviour {
public bool entered = false;
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == "Enemy")
entered = true;
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "Enemy")
entered = true;
}
private void OnCollisionExit(Collision collision)
{
entered = false;
}
}
“Enemy” is the GameObject and that should be detected once it’s entering the GameObject this script is attached to.
Entering or Collide with. But it doesn’t matter none of the events work. I used a breakpoint and it’s never get any of the events.