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 trialFerhat Aydemir
745 PointsWhy is the fly not getting destroyed?
I tried 3 times from the beginning and still cannot see where I am wrong.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class FlyPickup : MonoBehaviour {
void onTriggerEnter (Collider other) {
// If the collider other is tagged with "Player"...
if (other.CompareTag ("Player")) {
Destroy (gameObject);
}
}
}
1 Answer
Seth Kroger
56,414 PointsExact capitalization of the method name is important because you are filling in a predefined method. It should be OnTriggerEnter with the first O capitalized.
Ferhat Aydemir
745 PointsFerhat Aydemir
745 Pointswow I had corrected that error on my previous attempts and it did not work , somehow I missed it on this one and now it works, thank you pointing out.
joannadouba
558 Pointsjoannadouba
558 PointsYes!! This is it! Thank you Seth! Also, as mentioned in another thread, make sure that you change the name of the script from "FlyPickup" to "FlyPicking" or something of the sort as it's conflicting with something inside Unity.