OnCollisionEnter (C#)

I have a basic sphere going through a basic box that is a trigger. I cannot get the console to show that the trigger has been triggered. It’s dead simple so I don’t know what I’m doing wrong.

Here is the code attached to the box trigger:

using UnityEngine;
using System.Collections;

public class coll : MonoBehaviour {

// Use this for initialization
void OnCollisionEnter (Collision collision) {

Debug.Log (“Enter called.”);

}

void OnCollisionStay (Collision collision){

Debug.Log (“Stay occuring…”);

}

void OnCollisionExit (Collision collision) {

Debug.Log (“Exit called…”);

}

}

Thanks

2249372–150274–trial.zip (5.38 KB)

If you’re working with triggers and not collisions, you should be using the Trigger functions.

    void OnTriggerStay(Collider other) {
       Debug.Log ("Stay");
    }

    void OnTriggerExit(Collider other) {
       Debug.Log ("Exit");
    }

    void OnTriggerEnter(Collider other) {
       Debug.Log ("Entered");
    }

Hope this helps :slight_smile:

Oh perfect! I watched the Unity vid online and it used the collision code so I just assumed. Thanks!