- Home /
stop animations when an other animation is playing
guys please help , i have a parent(idle and walk animation) and a child(attack animation) object , they're both the same model , what i want to do is to hide the parent(idle,walk) when the child(attack animation) animation is playing
what is the script please !! thanks.
Answer by LightSource · Apr 06, 2013 at 04:03 PM
Ask for the component needed for the script, not the script itself.
You need animation.Stop:
http://docs.unity3d.com/Documentation/ScriptReference/Animation.Stop.html
Also here is the link to the new mecanim system in Unity 4 which will help you configure animations more fluidly:
http://docs.unity3d.com/Documentation/Manual/MecanimAnimationSystem.html
thanks for the reply , but i don't want to create realistic animations on mecanim , i already have my cartoonish animations for my character , can mecanim manage animations , not to create them ? thanks (y)
In the future, please post this as a comment, not a question.
$$anonymous$$ecanim is a animation managing software, but I do see your point.
Just try something like this:
 var beingAttacked : boolean = false;
 idle = true
 
 var idleAnimation : AnimationClip;
 var fightAnimation : AnimationClip
 
 function Update () {
 
 if (beingAttacked == true) {
 
 animation.Stop ("idleAnimation");
 animation.Play ("fightAnimation");
 
 idle = false;
 
 }
 
 if (idle == true) {
 
 animation.Play ("idleAnimation");
 animation.Stop ("fightAnimation");
 
 beingAttacked = false;
 
 }
 
 function Attacked () { //When attacked
 
 beingAttacked = true;
 
 }
 
 function Idle () { //When Idle
 
 idle = true;
 
 }
 
 
 
Answer by Brainswitch · Nov 11, 2013 at 02:02 PM
Another way to do this is to use AnimationState.layer, if all your AnimationStates have weight 1 that means the state with the highest layer will be the only one playing.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                