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

Hayley McLaren
Hayley McLaren
259 Points

Fly Doesn't disappear, Player is not defined

Every time I test the game the fly doesn't disappear and at the bottom of the screen I get an error message that says "UnityException: Tag: player is not defined.". I've checked the video several times and I can't find anything wrong with the code. What did I do wrong?

using UnityEngine; using System.Collections;

public class FlyPickup : MonoBehaviour {

void OnTriggerEnter(Collider other) {

    //If collider other is tagged tagged with "player"
    if (other.CompareTag ("player")) {

        Destroy (gameObject);

    }
}

}

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Remember that most programming languages are case-sensitive. You should be looking for the tag "Player", but you've typed "player". Try capitalizing that correctly and see if it makes a difference!

Good luck! :sparkles:

Hayley McLaren
Hayley McLaren
259 Points

That fixed it, thanks for the help!