CharacterController and Collider problem....

hello everyone.
Now I have a problem.
In my project, I make a character and an AI.

I make a sample script let the AI can attack and make damage to my character like this…

In AI…

function OnTriggerEnter (other : Collider) {
  if(other.gameObject.tag=="player"){
    other.gameObject.SendMessage ("ApplyDamage");
  }
}

In character…

function ApplyDamage(){

  HP--;

}

but my character don’t get any damage when the AI attack…

and I find a interesting phenomenon.

when my character stay and not move,I can’t get any damage.
bug when I move, I can get damage!

Move>>I can get damage.
Stay>>I can’t get damage.

Have any idea to fix the bug??

1 Answer

1

Had the same issue. It turns out that Colliders do not cause nearby objects to “wake up” when enabled. You need to add a RigidBody to your Collider (the one with the OnTriggerEnter() on it).