Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by bfbc2jb · Dec 29, 2012 at 08:20 AM · animationjavascript

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

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.

Comment
Add comment · Show 10 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image bfbc2jb · Dec 29, 2012 at 12:42 PM 1
Share

what .enabled?, like "AnimationState.enabled=true"?, can you put it on script im confused

avatar image whydoidoit · Dec 29, 2012 at 12:57 PM 0
Share
 function Update () {
     for (var state : AnimationState in animation) {
         if(Input.Get$$anonymous$$ey("x")) {
             state.speed = animationSpeed;
             state.enabled = true;
             state.weight = 1;
         }
     }
 }
avatar image whydoidoit · Dec 29, 2012 at 02:12 PM 1
Share

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;
     }
avatar image whydoidoit · Dec 29, 2012 at 04:26 PM 1
Share

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);
avatar image bfbc2jb · Dec 29, 2012 at 04:53 PM 1
Share

thanks, all working now, im done here. much appreciated

Show more comments
avatar image
0

Answer by Legend of Hibiki · Dec 29, 2012 at 11:37 AM

hi,

try animaion.Play("name");

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image bfbc2jb · Dec 29, 2012 at 11:44 AM 0
Share

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?

avatar image
0

Answer by FlammingFart · Dec 29, 2012 at 12:17 PM

what file name does unity accepts?

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image bfbc2jb · Dec 29, 2012 at 12:18 PM 0
Share

what do you mean?, if you mean the models i import with the animations then i use the fbx exporter for 3ds max

avatar image FlammingFart · Dec 29, 2012 at 12:53 PM 0
Share

i mean.. does unity accepts .max file

avatar image bfbc2jb · Dec 29, 2012 at 12:54 PM 0
Share

dont think so, i dont know, havent tried. why, whats this have to do with my question

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

How to I vary animations based on proximity? 2 Answers

How to change a variable in the same script? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges