I have two objects; an enemy object and a bullet object. They both have 2Dboxcolliders and 2Drigidbodys and the bullet object has ‘Is Trigger’ set to true.
In the enemy script I have the following based off of a tutorial:
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.CompareTag("Bullet"))
{
sr.material = matwhite;
Debug.Log("got shot");
Destroy(collision.gameObject);
health--;
if (health <= 0)
{
KillSelf();
}
}
}
When making contact with the enemy however, the bullet will just go right through and not collide at all,
I have checked that the bullet does have the bullet tag, I’m not sure what is causing the problem since it seems to work well enough in the tutorial i am following and i am pretty sure i have everything else the tutorial needs. However if there is another fairly straightforward way to fix my problem apart from this am open to suggestions.