mecanim animations work with one script but can't be found with another....please help

I have one script that triggers mecanim animations on the player by pressing keys. This works fine. When I try to do a script to trigger the animations with a collider trigger I get an error that the animation couldn’t play because it couldn’t be found.

Can anyone help me to figure out why it can find the animation and apply it with the keyboard trigger method but not the collider trigger method?

I’m totally lost and have been looking for a solution for weeks in the forums and on Unity Answers and YouTube with no success.

Please help.

Post your code if you need the help.

thanks for the response. This is the code:

#pragma strict

function OnTriggerEnter (collision : Collider) {

if (collision.gameObject.tag == "Player"){

collision.gameObject.GetComponent.<Animation>().Play("bench sit new");
}
}

It seems to want to work but for the fact that it states it can’t find the animation. It finds it on keyboard press though.

Without seeing the other code that works, I can only tell you possible issues.

1 make sure that the gameobject with the tag “Player” has the Animation component. It can’t be a parent or child.

  1. Make sure that there are not other gameobjects (even children) that have the Player tag AND don’t have an animation component…that will cause the code to fail.