- Home /
onTriggerEnter issue? This should work!
Hello,
So I've been using this piece of code for a while but somehow, this doesn't work on my latest setup? I'm using a sphere with a box collider, it IS a trigger and other box collider it enters (which have the same code) do get destroyed, just not this one? Any ideas?
void onTriggerEnter (Collider collider)
{
if (collider.gameObject.CompareTag("DMG"))
{
Debug.Log("Trigger Entered");
Player.score += 50;
Destroy (this.gameObject);
}
}
Thanks,
Comment
Best Answer
Answer by azmat786n · Dec 30, 2013 at 09:13 PM
/////Bug is here O should be capital of OnTriggerEnter
//void onTriggerEnter (Collider collider)
void OnTriggerEnter (Collider collider)
{
if (collider.gameObject.tap == "DMG")
{
Debug.Log("Trigger Entered");
Player.score += 50;
Destroy (gameObject);
}
}
when you find helpful answers don't forget to thumb up them..