Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development How to Make a Video Game Pickups Script the Fly Pickup

Chris Vaisanen
Chris Vaisanen
3,097 Points

My fly won't disappear either.

After going through all these Q&A's about other people having this issue none of it has helped. My code looks correct. The fly is attached to the script. The "Player" is tagged to "Player". Also the Fly is set to "Center" in Geometry and the "Is Trigger" is checked. Anyone have any other suggestions ?

public class FlyPickup : MonoBehaviour {

void OnTriggerEnter (Collider other){

    //If the Collider other is tagged with "Player"
    if (other.CompareTag ("Player"))
    {
        Destroy (gameObject);
    }
}

}

1 Answer

victorhuang
victorhuang
4,322 Points

You codes look just fine. But make sure that your FlyPickup script is set in Fly object hierarchy instead of child class Geometry.