- Home /
punching animation/reaction
I am having problems. I have a sphere collider as a child to my characters hand. It is called "fist" and tagged "Siren". And I have a player punching animation. I want that when the "fist" hits the sphere collider on the enemies head for it to trigger an enemy animation called "EnemyDie". SO the fist isn't always active, I have an animation on it to where the mesh render and trigger function channels of the fist are off unless i press mouse 0 ( my button to punch). I watch in the inspector and see that it "works" as I see the "is trigger" checkbox go on and off as well as I visually see the sphere in the scene window turn on the mesh during the punch. Problem is , when the enemy comes at me I can just be idling and the "die" animation on the enemy is triggered. Seems simple enough but I can't figure it out. I guess the enemy is reacting to my player collider var EnemyDie : AnimationClip; var PunchSound : AudioClip;
function OnCollisionEnter (fist : Collider) {
if(fist.tag=="Siren")
GameObject.Find("Enemy").animation.Play("EnemyDie");
AudioSource.PlayClipAtPoint(PunchSound, transform.position);