Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The weapon is not colliding with the AI

    private void OnTriggerEnter2D(Collider2D collider)
    {
        Debug.Log(collider.gameObject.tag);
    }

When it collides with the weapon (or anything) it should print the tag. The problem is that it doesn’t print anything.
enter image description here

Here you can see the player (normal colours) hitting the AI (green) and I am 100% that the AI is within the bounds of the weapons hitbox.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The AI layer and the player layers do interact with each other.
enter image description here

This is the box collider on the weapon (ignore it being disabled)

enter image description here

This is the box collider on the AI.
I have tried using ontriggerenter2D, ontriggerstay2D, ontriggerexit2D, ontriggerenter, ontriggerstay, ontriggerexit, oncollisionexit, oncollisionstay. I honestly have no clue why it is like this.

I know that it is not entering the on collision enter because it should be printing the ground tag that I have on the ground. Also the game is in 2D.

>Solution :

The Rigidbody has to be on the same Game Object as the script for the collision/trigger enter and exit methods to be called.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading