Where To Start

For Collisions and/or Triggers to work you need to have Collider Components on both GameObjects and one of them needs to have a Rigidbody(Physics Component). Also to make life easier you will want the script on the same GameObject as the Rigidbody and Collider. There are ways to get to them thru code by tunneling up or down thru inheritance or hierarchy but can be a pain to get working and to trouble shoot.

  • OnCollisionEnter OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.
void OnCollisionEnter(Collision collision) {
  Debug.Log ("Entered");
  • OnCollisionExit OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.
void OnCollisionExit(Collision collision) {
  Debug.Log ("Exited");
  • OnCollisionStay OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.
void OnCollisionStay(Collision collision) {
  Debug.Log ("Still here");
  • OnTriggerEnter OnTriggerEnter is called when the Collider other enters the trigger.
void OnTriggerEnter(Collider other) {
        Debug.Log ("Trigger Entered");
  • OnTriggerExit OnTriggerExit is called when the Collider other has stopped touching the trigger.
void OnTriggerExit(Collider other) {
        Debug.Log ("Trigger Exited");
  • OnTriggerStay OnTriggerStay is called almost all the frames for every Collider other that is touching the trigger.
void OnTriggerStay(Collider other) {
        Debug.Log ("Still in Trigger");