I have a player sphere with RigidBody
, SphereCollider
and two empty child gameObject both have RigidBody
, SphereCollider
as the trigger, and a script of their own to handle the OnTriggerEnter
. One is bigger to check if the enemy was in sight range, and another one is smaller to check if the enemy is in attack range.
When I test it out, it worked for “couple times” and then it stop working!!!
Could somebody please tell me what did I do wrong, please!?
Much appreciated!!!
In sight trigger:
public class Trigger : MonoBehaviour {
private void OnTriggerEnter(Collider other)
{
if(other.tag=="Enemy") Debug.Log("Enemy in sight!");
}
}
Attack trigger:
public class Attack : MonoBehaviour {
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Enemy") Debug.Log("Attack!");
}
}