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 /
This question was closed Jan 02, 2015 at 08:20 PM by Hronet for the following reason:

Other

avatar image
0
Question by Hronet · Dec 31, 2014 at 12:45 AM · animatormecanimdynamicanimationclipunity4

How can I make my Animator State's Motion looping dynamically?

I am dynamically creating Animation Clips and assigning them to an Animator at runtime. The Animator itself never changes, however the animations may need to change depending on the circumstances of the game. For instance, during one animation the object may need to animate from 0,0,0 to 0,15,0 along the Y-Axis. The next time I ask my Animator to play I need the same animation but this time it should move from 0,0,0 to 0,32,0 or something random like that. The gist is that the Animator will remain, the states won't change, but the animations will be slightly altered, rebuilt, and reassigned before I tell the object to animate again.

Now on to the problem! I have successfully done this all and reassigned my animation clip, that part was alright. The problem that I have now is that when I was animating with a static animation that I had generated by hand it was easy to tell it to loop that one second animation ten times, I just changed the Exit Time to 10.0. Now when I add my auto-generated animation, the Exit Time is still 10 seconds however the animation itself only ever plays once, despite having marked it as WrapMode.Loop while creating it. I'll post as much relevant code as I can to try and help people understand what I'm going for here.

 var newAnimationClip = new AnimationClip();
 
 var curve = AnimationCurve.Linear(0, 0, 1 / speed, moveToPosition);
 
 newAnimationClip.SetCurve("", typeof(Transform), "localPosition.y", curve);
 AnimationUtility.SetAnimationType(newAnimationClip, ModelImporterAnimationType.Human);
 newAnimationClip.wrapMode = WrapMode.Loop;
 
 GetStateFromObject(go, "MyState").SetAnimationClip( newAnimationClip );

Thanks for any and all help!

Edit : So the approach I am going to attempt is to not reuse already created transitions, but generate my own and hope that during this process it will automatically loop the motion appropriately for the exit time. I'll update this if I find success doing so.

Edit2 : Yeah that really did not work. I don't think there was ever any intent in Unity 4 for people to edit Animator and their States' motions the way I'm trying to and it's going to end up being way more work to get this to function properly than is worth.

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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

25 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how to go to last frame of animation clip immediately? 1 Answer

Getting the position of an object in an AnimationClip ? 1 Answer

Edit AnimationClip during runtime from script 0 Answers

animation to animator [mecanim] 1 Answer

Is there a way to change the WrapMode of all Animations in a Mecanim Animator? 1 Answer


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