ChronicleEdge
ChronicleEdge

Reputation: 19

Enemy won't get destroyed when I hit it

private void OnTriggerEnter(Collider other)
    {
        if(other.tag == "Melee")
        {
            Destroy(gameObject);
        }
    }

The code shown above is the code in my enemy script that lets it die when the player's knife hits it. The knife is tagged as Melee. When the knife hits the enemy, it doesn't get destroyed.

Upvotes: 0

Views: 74

Answers (1)

Bipin
Bipin

Reputation: 451

Things you can check.

  1. Is your collider 3D?

  2. At least one of the two colliding objects must have a Rigidbody.

  3. Also make sure the typo in "Melee".

  4. One more thing, Make sure your collider is in Trigger Mode.

Upvotes: 1

Related Questions