- Home /
OnControllerColliderHit works on 2 character controllers
Hi everyone, I have been reading alot and having a hard time to get the OnControllerColliderHit works on 2 character controllers. (one from enemy , another from player char)
This is the enemy side script. At the moment, when ever its on the floor, the hit.object.name is the floor. But when I try to debug hit.controller, its printing the enemy's controller (itself). I wonder why its is not able to detect my player ? I'm sure I have tag everything right. Thank you.
function OnControllerColliderHit(hit:ControllerColliderHit)
{
hit.collider.renderer.material.color = Color.red;
if(hit.gameObject.tag == "Player")
print("hit");
if(hit.controller.tag == "stage")
return;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613095041im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Jaggie, uneven speed with basic movement script. 0 Answers
How to change float animator parameters on an NPC object? 0 Answers
Enemy controller.move script slows down and speeds up. How to get it consistent? 0 Answers
Guiding a character while falling 0 Answers
Jump gets disabled with courutine! 1 Answer