- Home /
collider animation
Hello Unity3D i have a little problem with my collider.The problem is that i want my collider to play a hit animation when i punch or kick it and not when i run to it or my collider and my opponents collider gets near enough.How do i make it that the collider's animation only work when i punch or kick it and nothing else?If anyone knows.Can you please tell me how i can fix this problem?
Also i have rigidbody on my characters and they have "is kinetics" checked and i have sphere colliders on my characters arms and legs and they have is triggered checked #pragma strict
var setOnFire : ParticleSystem;
function Start ()
{
setOnFire.Stop();
}
function OnTriggerEnter (Col : Collider)
{
if(Col.tag == "Player")
if(!animation.IsPlaying("Reverse_Crescent"))
if(!animation.IsPlaying("Flurries"))
if(!animation.IsPlaying("Spinning_back_kick"))
if(!animation.IsPlaying("Spinning_back_kick2"))
if(!animation.IsPlaying("Jump_Spinning_Back_Kick"))
if(!animation.IsPlaying("Astral_Ball"))
if(!animation.IsPlaying("Kick_Combo"))
animation.Play("Hit1");
{
setOnFire.Play();
}
}
Answer by Raggers · Sep 22, 2014 at 01:26 PM
Don't know if this is best practice but, disable the colliders on the arms and legs. Then if you kick you re-enable them for the duration of the kick. After that you turn them back off.
Your answer
Follow this Question
Related Questions
Unity 4.5.2 bug changing the properties of the 2d colliders in animation 1 Answer
Triggering door animation with collider 2 Answers
Play animation when colliding with trigger! 3 Answers
Is there any good method to keep the collider constant while the local scale shrinking or expanding 1 Answer
Health bar isn't decreasing. 2 Answers