- Home /
cannot get animation to play
the code is not complete but as testing it the animation should play. but it does not, and im confused why and i need help cause i cant figure why it would not play. basicly what im doing is coding the animation of the landing things for a anti gravity vehicle saucer.what i cant figure and ive been trying for ages with no success, i cant get the anim to actaully play when i press x and have the ping pong mode so the landing claws deploy/undeploy wheni press x, this is the incomplete code but it should be working, but the anim does not play
 var animationSpeed:float;
 
 function Update () {
     for (var state : AnimationState in animation) {
         if(Input.GetKey("x"))
         state.speed = animationSpeed;
     }
 }
thanks is advance really apreciate it, thanks
Answer by whydoidoit · Dec 29, 2012 at 12:34 PM
You need to set .enabled = true on the animation and give it .weight > 0 to have it cause an effect.
what .enabled?, like "AnimationState.enabled=true"?, can you put it on script im confused
 function Update () {
     for (var state : AnimationState in animation) {
         if(Input.Get$$anonymous$$ey("x")) {
             state.speed = animationSpeed;
             state.enabled = true;
             state.weight = 1;
         }
     }
 }
Well you want the animation wrap$$anonymous$$ode set to ClampForever.
Then you need to reverse the speed to make it close.
Perhaps something like:
     if(Input.Get$$anonymous$$ey("x")) {
         if(state.normalizedTime > 0.01f)
         {
               state.speed = -animationSpeed;
         }
         else
         {
               state.speed = animationSpeed;
         }
         state.wrap$$anonymous$$ode = Wrap$$anonymous$$ode.ClampForever;
         state.enabled = true;
         state.weight = 1;
     }
Sure just add this:
   state.normalizedTime = $$anonymous$$athf.Clamp01(state.normalizedTime);
Or if that is flaky
   state.time = $$anonymous$$athf.Clamp(state.time, 0, state.length);
Answer by Legend of Hibiki · Dec 29, 2012 at 11:37 AM
hi,
try animaion.Play("name");
yes that works but i need to use AnimationState etc... so i can make the landing gear retract and deploy not just replay when i press it, thing is though i cant get it to play using AnimationState. or is there another better way?
Answer by FlammingFart · Dec 29, 2012 at 12:17 PM
what file name does unity accepts?
what do you mean?, if you mean the models i import with the animations then i use the fbx exporter for 3ds max
dont think so, i dont know, havent tried. why, whats this have to do with my question
Your answer
 
 
             Follow this Question
Related Questions
In-depth Animation and Audio guide for Enemy AI? 1 Answer
Respawn on Collision Problems. 2 Answers
Attack Animation through Javascript 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                