Jay
Jay

Reputation: 67

Collider2D collision not working in Unity

Question: Why isn't this code working from inside the power up script ?

    private void OnTriggerEnter2D(Collider2D other)
    {


        if (other.tag == "Player")
        {
            Debug.Log("I got power up");


            Destroy(this.gameObject);
        }




    }

So I have two game objects.

Triple_Shot_Powerup and Player

When these two collide nothing is happening...idk why

enter image description here

Player has:

Tag:Player

Box Collider 2D with Trigger True

and Has a Rigid Body

enter image description here

Triple_Shot_Powerup has:

Box Collider 2D with Trigger True

and Has a Rigid Body

enter image description here

Upvotes: 0

Views: 108

Answers (2)

waqasbutt028
waqasbutt028

Reputation: 41

You dont need rigid body on both objects. if you have rigid body attached to both object make sure your rigidbody Checkbox must be checked

Upvotes: 0

Jay
Jay

Reputation: 67

Rigidbody Simulated Checkbox must be True

Upvotes: 1

Related Questions