3D triggers not detecting rigidbody
I'm just trying to build a simple trigger detection script but the basic trigger system is not working. Not even the debug messages in the script show up in the console. I've tried with a box collider trigger and a sphere collider trigger (making sure "Is Trigger" is checked of course). The entering objects always have a rigidbody component. So what is the obscure "X-factor" not covered in documentation and tutorials that's got me stymied?
using UnityEngine;
using System.Collections;
public class TriggerScript : MonoBehaviour {
void onTriggerEnter(Collider other)
{
Debug.Log("Object entered trigger");
}
void onTriggerExit(Collider other)
{
Debug.Log("Object exited trigger");
}
}
Answer by Cepheid · Sep 15, 2016 at 01:55 AM
Hi @AviKohl3D
The problem you're facing is as simple as a typo. You've misspelled the OnTriggerEnter methods. Every method name provided by Unity's base MonoBehaviour must be typed in Pascal case. So, just change your "onTriggerEnter" to "OnTriggerEnter" and you're good to go!
Your answer
Follow this Question
Related Questions
respawning with triggers in unity,How do i make only my player respawn? 0 Answers
3D Trigger collider slows player moved by forces 0 Answers
onTriggerEnter returns wrong object's attribute 1 Answer
multiple objects with triggers that need to ignore the triggers but still collide with eachother? 0 Answers