I am trying to add 2 colliders onto my enemy game object. One for the vison range and one for the attack range. I have two scripts that work together to check if the collider has been triggered. One generic detector script that is just used to run an event if the trigger is entered. and then my main enemy script.
player is assigned as public GameObject player
`public void OnVisionTriggerEnter(Collider2D other)
{
Debug.Log("OnVisionTriggerEnter");
if(other.tag == player.tag)
{
Debug.Log("OnVisionTriggerEnter");
if (other == player.GetComponent<Collider2D>())
{
Debug.Log("OnVisionTriggerEnter");
isFollowing = true;
}
}
}`
This is my trouble block right now. Neither of the if statements will pass but the function as a whole is running. I'm at a loss of what to do
I tried multiple different ways to check if the game object that entered the trigger was the player including:
as it's written
GameObect test = other.gameObject;
if(other.gameObject == player)
If the "if" statement would pass the rest of the code works fine.