- Home /
 
 
               Question by 
               WhiskeyJack · Nov 01, 2010 at 03:59 PM · 
                rigidbodycollidertriggerontriggerenter  
              
 
              Can't get trigger to work
How do I create a trigger? Seems simple enough, but I can't get it to work. I tried this:
- Create GameObject --> Cube
 - Tick "Is Trigger" in the Box Collider section of the Cube
 - Create a script triggerTest and attach it to the cube (script below)
 - Put a First Person Controller from the Standard Assets in the scene
 
I can walk through the box, but the trigger is never activated. I have also tried adding a rigid body to the First Person Controller. This is the code I have in triggerTest.cs:
using UnityEngine; using System.Collections;
 
               public class triggerTest : MonoBehaviour {
 
                void onTriggerEnter(Collider other) {
     Debug.Log("Trigger triggered");
 }
  
               } 
What am I missing here?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by lhk · Nov 01, 2010 at 04:54 PM
You need to write OnTriggerEnter instead of onTriggerEnter. The function starts with an uppercase letter.
what about if u wanted to have it appear when it hits the trigger?
Your answer