Hi sry for noobish question, but i can’t handle it by myself…
In my game player can pick boxes and throw’em at enemies to kill. Enemies are using CharacterController, here’s a code:
void OnControllerColliderHit(ControllerColliderHit hit) {
if(hit.gameObject.tag == "pickBox"){
if (hit.rigidbody.velocity.magnitude > 5)
Debug.Log("HIT!");
}
}
but it’s not debugging…
you want to destroy character? or want to destroy enemy?
not sure if i understood your question… my enemies are using character controller to move, i’m throwing boxes at tham. I want to “destroy” enemy only if box’s velocity is greater than 5. I’m using OnControllerColliderHit to detect collisions.
Ok,
If this code you provided is attached with the enemy then i see there’s no problem with it. May be I failed to figure it out 
If the code is attached with the pickbox or player(the character who is throwing the boxes) then the script is incorrect. Then the code may look like this,
Sometimes Debug.Log() doesn’t work right. Try Destroy() function to eliminate your enemy. Check if it works.
I thinks this might help.
Thanks,
_Masudias
From my experience OnControllerColliderHit is only ever called when the CharacterController hits something during a move. It does not trigger when something else hits the CharacterController. So your should use OnCollisionEnter instead.
void OnControllerColliderHit(ControllerColliderHit hit)
{
Debug.Log("I hit something");
}
void OnCollisionEnter(Collision collision)
{
Debug.Log("Something hit me");
}
Give this code a go
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag == "pickBox"){
if (collision.rigidbody.velocity.magnitude > 5)
Debug.Log("HIT!");
}
}
}
Hope this helps,
Taz