I have already figured it out.
But i have another problem now
i want my character to use the punch animation on colliding with the player but its not working this is the script
var Myself : Transform;
var AttackorNot : int;
function Update () {
if(AttackorNot == 1){
Myself.animation.CrossFade("punch");
}
}
function OnTriggerEnter(other:Collider){
if(other.gameObject.CompareTag("Player"))
{
AttackorNot = 1;
}
}
Myself is the main object which have this trigger
so i set this boolean function that if it will collide with the player the boolean will be 1
and in the update function i used this boolean function to run the animation on the main Object.