- Home /
Question by
NRockhouse · Aug 23, 2012 at 07:43 AM ·
oncollisionenterfirst person controller
First Person Controller Colliding Fail
var floor:GameObject;
function OnCollisionEnter(collision : Collision) {
if(collision != floor) {
Debug.Log(collision.gameObject.name);
}
}
I tried the above code to a cube and when I go near the cube with the first person controller, the first person controller cannot be detected. Can anyone tell me why? I tried delete "if" part but it only says "Floor". Please help me.
Comment
do you have a collider, on your controller?
or, is it constantly colliding with the floor so you never get to collide with the box?
Dont worry about the floor. Define what you are colliding with. Use names or tags : if(collision.gameObject.tag == "objectToCollideWith")