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

How to Make a Video Game

I followed the code exactly like the video explained. I went on other student questions to see if i could find a solution and read all 9 questions. I followed what answer was given to each student but still can't get fly to disappear . The project was flowing but now I'm stuck and it still won't make fly disapear . Heres my code and i also attached screen shot were i attached fly object to fly pick up script and were i attached player to player movement script but it still won't work.

sing UnityEngine; using System.Collections;

public class FlyPickup : MonoBehaviour {

void OntriggerEnter(Collider other){
    // If the collider other is tagged with "player" ...
    if (other.CompareTag ("Player")) {

        // ...add the pickup particles...

        Destroy (gameObject );

    } 

}

}

/Users/reginaldaugustin/Desktop/Screen Shot 2016-10-25 at 1.39.07 PM.png /Users/reginaldaugustin/Desktop/Screen Shot 2016-10-25 at 1.34.05 PM.png

i finally got it to work!!! i copied this code from one of the student answers i pasted it in monoDevelop and built it and it compiled switch back to unity game engine press play and the fly disappeared. here is the code that i copied.

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);

    }
}

}

Annet de Boer
Annet de Boer
900 Points

Thanks for taking the time to share your solution as well! As I look at the two screenshots it seemed to have been the capital "T" on OnTriggerEnter.

1 Answer

Thanks