player detection

Hey guy’s im stuck on this… So I have a 6 boxes in my scene, and they all have box colliders on them, and a script to detect if something touches them.

function OnCollisionEnter(collision : Collision) {
  if(collision.gameObject.tag=="Player"){ 
	
 }
 print(collision.gameObject.tag);
}

It detects if a box has fallen on it, but I want it to detect if a player walks on it…
The code above doesn’t detect if my player walks or jumps or does anything on it…
Its very frustrating.

Thanks for the help

You’re gonna have to manage the collision-detection on the Player-GameObject, as OnCollision functions are not supported with CharacterControllers.

Use this function to detect collisions with the player

Put Rigidbodies on your boxes and you should get collision events.

you have to use

function OnControllerColliderHit (hit : ControllerColliderHit) : void 

OnCollisionEnter does not work on character controller

go to
http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.OnControllerColliderHit.html for more details