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 Add Pickup Particles

Cant see prefab script...

I have coded as instructed....

using UnityEngine; using System.Collections;

public class FlyPickup : MonoBehaviour {

[SerializeField]
private GameObject pickupPrefab;

void OnTriggerEnter(Collider other) {

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

        // ...add the pickup particles...
        Instantiate(pickupPrefab, transform.position, Quaternion.identity);

        Destroy (gameObject);

    }
}

} ....within FlyPickup.cs, saved, then saved the scene, but when I go the Fly object, there is no additional script. Could someone please help? And also, now my fly doesn't disappear, when I launch the game. Until I amended this script from the last lesson, the fly did disappear.

2 Answers

Stéphane Diez
Stéphane Diez
19,350 Points

You can just drop the fly prefab in the hierarchy and then pick up your script an drag it "IN" the fly object. So you see at the INSPECTOR of the fly object , the script : FlyPickup attached. I'm at work right now, so I can't get my unity open to help you, but try this. Or post a screenshot for me so that I can help you better.

Thank you SO much Stéphane. That was worked! I was worried that I would have to start all over again! Thank you.