Can not get onTriggerEnter and onCollisionEnter to work!?
I can not get OnTriggerEnter or OnCollisionEnter to work. I have two objects with colliders and one of them has rigid body. Here are the inspectors of both of the objects, so you might see what is wrong.
First is the cube, which has the rigidbody attached and is the one moving during the collision.
Here is the second. This is the plane that the cube is colliding with.
This is the code I am trying to use to just print out a simple debug.log.
using UnityEngine;
using System.Collections;
public class CharacterScript : MonoBehaviour {
void onCollisionEnter(Collision collision){
Debug.Log (collision.gameObject.name);
}
}
I have looked through the documentation for a while, and nothing appears to be wrong, so I am stumped. Any help is appreciated. Thanks so much!
Answer by Payton-Dugas · Sep 26, 2016 at 07:06 PM
WOW! Thanks lot. Now I'll make sure to check the case in documentation whenever I have another problem.
Answer by Landern · Sep 26, 2016 at 05:05 PM
It should be:
using UnityEngine;
using System.Collections;
public class CharacterScript : MonoBehaviour {
// Capital O on "OnCollisionEnter" the method names are case-sensitive.
void OnCollisionEnter(Collision collision){
Debug.Log (collision.gameObject.name);
}
}
Your answer
Follow this Question
Related Questions
C# OnTriggerEnter Issue 3 Answers
Wall Collisions with manual position update 0 Answers
Problem With Triggers? 0 Answers
Triggering Particle With Box Collider? 0 Answers
collider triggers 0 Answers