Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by fronzu · Oct 09, 2017 at 01:05 PM · animationanimatorimportmodelanimationclip

How to get and use animation clips of a model via script?

Hi!

I need to play the animations of an object on the object itself, and I need to do that at runtime. But how can I get the animation clips of the object so I can assign them to the AnimationController?

Thanks in advance and have a nice day!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Yuvii · Oct 09, 2017 at 02:19 PM

Hey,

Not really sure about what you're asking but i'll give a try. When you have your fbx file with your animation(s) imported in unity, then click on it and in the Inspector>Animations you have a timeline wich represents the animation(s) timeline in your fbx file (of course).

Let's assume that the complete timeline defines only one animation, like the walk loop. (then you probably should rename that animation "walk" (set it above the timeline)). If you go to the animator window (Window>Animator) you should see your walk animation in it (in orange if it's the default animation, which means it will play the animation on start of animator) ot grey (not default). You should have at least two animations if you want to be able to switch from one to an other.

Then in Animator Window>Parameters you can set your own parameters that you will be able to modify in script.

For example, let's say i have two animations : Idle and Walk. I have one parameter which is a boolean 'isMoving'. So i make a transition in the animator window from Idle to walk and set the condition to 'isWalking' > true and a transition from Walk to Idle with the opposite condition.

Now in the code, it's basically something like that

 Animator anim;
 public h;
 public v;
 
 void Start(){
     anim = GetComponent<Animator>();
 }
 
 void Update(){
 
     h = Input.GetAxis("Horizontal");
     v = Input.GetAxis("Vertical");
 
     if(h != 0 || v != 0){
         anim.SetBool("isWalking", true);
     }
     else{
         anim.SetBool("isWalking", false);
     }
 }







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 fronzu · Oct 09, 2017 at 09:11 PM 0
Share

Hey thanks for the answer!

I'm sure this will be very useful for a lot of people, but I think I didn't explain well, because my problem was to extrapolate and assign to an Animation Controller, the Animation Clips inside a model.

However I solved it by using Asset Bundles and the command LoadAllAssets(). The Asset Bundle contained my .fbx model and all its component split into single and accessible components (this was automatically made by Unity at the moment of creating the bundle).

As I said, thanks anyway for the answer and have a nice day!

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

191 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 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 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 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 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 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 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 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

Model not playing Animations 0 Answers

play animation forward and then in reverse 1 Answer

Animator Override Controller changed at runtime doesn't always play the animations correctly 1 Answer

Parameterized Animation Clip 0 Answers

How to edit read only animations 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