Character Controller, and a Enemy.

I have 2 things in my project. A main character, and a enemy. My main have a Character Controller and a Third Person Controller script, a Rigidbody, and no Colliders [character controller has one]. My enemy have a box collider, and a script that say if my main character collide with him, it will do the “hit” animation, and will be “destroyed” right after. Not worked. After a lot of work, I discovered that the supposed problem is the ‘‘Character Controller’’ Collider does not work too good. What I supposed need to do is to erase the ‘‘third person controller’’, and the ‘‘character controller’’, but with myself, the ‘‘Third Person Controller’’ works very well with the Main Character movimentation. But I don’t want to make a new script to the character move with W,A,S,D, and make the determined animations that I have attached to it. What I can do to my ‘‘enemy’’ recognize the Collision?

#pragma strict
var idling:boolean=true;
functionStart(){
}
functionUpdate(){
if(idling)animation.Play("Principal");
}
functionOnCollisionEnter(collision:Collision)
{
if(collision.gameObject.tag =="Player")
{
animation.Stop();
idling =false;
animation.Play("Hit");
Destroy(gameObject,2);
}
}

Sorry for my horrible English, I’m Brazilian. Thnx for help!

It’s a little hard to believe a box collider isn’t detecting a character since we are all doing this constantly with triggers and having no problems. Perhaps you should just start with a collider and use debug on it.

  • if(collision.gameObject.tag ==“Player”)
  • {
  • Debug.Log(“character collided”);
  • }

I will try to make a video showing the problem

Make sure you have a single Collider on the enemy or the player.