Nasir Khan
Nasir Khan

Reputation: 37

SetActive not working in Unity3d?

Learning Roll a ball project from unity project, and pickup do not remove when player collides with them. it just go through inside them like a transparent object, here is my code.

void onTriggerEnter(Collider other) 
{
    if(other.gameObject.tag == "Pickup")
    {
      other.gameObject.SetActive(false);
    }
}

Upvotes: 2

Views: 1441

Answers (1)

Stefan Hoffmann
Stefan Hoffmann

Reputation: 3234

I see one, maybe two problems with case sensitivity in your code.

  1. the method's name is OnTriggerEnter, note the capital 'O'. Unity uses a case sensitive search when it looks for methods to call.
  2. tags are case sensitive, too. The tutorial uses PickUp as tag, so make sure your code matches the tag you set in the Unity Editor.

Upvotes: 3

Related Questions