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 /
  • Help Room /
avatar image
0
Question by SepraB · Sep 14, 2016 at 12:27 PM · scripting problemanimatorcontroller

RuntimeAnimatorController not loading from script

Hi, I have a problem when loading a RuntimeAnimatorController from the script. I have been looking throug any avialable forum or tutorial on internet but I still haven't found the solution.

 public RuntimeAnimatorController animSit;
 
     public void animar(GameObject paciente)
     {
         Animator sentado = paciente.GetComponent<Animator>();
         //sentado.runtimeAnimatorController = Resources.Load("Assets/animControl/H_B_obeso_contr") as RuntimeAnimatorController;
         sentado.runtimeAnimatorController = animSit;
     }

Both of the ways I'm trying to add the AnimatorController doesn't work. It keeps the AnimatorController in blank.

alt text

If during runtime I add the Controller through the Inspector, it works!! but I need to add it from the script because I'm instantiating the GameObject.

I really apreciate if you have any kind of solution, been trying to solve this for a long time.

captura.jpg (20.5 kB)
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

4 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by TXrTim · Jul 04, 2018 at 06:06 AM

I don't agree with "Best Answer".
Currently I'm on latest beta 2018.2.0b9 Personal and here's what could be the root cause: If my RuntimeAnimatorController is not placed in \Resources\ folder script will behave just like in your situation - no errors, no warning and if you select animator in inspector it still "None". BUT! After i placed RuntimeAnimatorController in \Resources\ everything started working.

Summary:

Step 1: Place RuntimeAnimatorController into \Resources\ folder. Lets say file name will be "MyController.controller".

Step 2:

 var animator = gameObject.AddComponent<Animator>();
 animator.runtimeAnimatorController = Resources.Load<RuntimeAnimatorController>("MyController");










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 Stefanitsky · Aug 26, 2018 at 03:34 AM 0
Share

Nice! Simple and usefull solution.

BTW, it's not an error or something like a bug. Official Wiki: "Load - Loads an asset stored at path in a Resources folder." https://docs.unity3d.com/ScriptReference/Resources.Load.html

avatar image
1

Answer by SepraB · Oct 15, 2016 at 02:11 AM

After many tries, the answer is simple.

By this version of Unity, there is an obligation where you have always to set the controller before you run the scene. It is impossible to add the controller to the RunTimeAnimatorController without a a controller.

Just answering myself because if someone have the same answer.

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 B3BO · May 29, 2018 at 01:53 PM 0
Share

have you ever found a solution/workaround?

avatar image
0

Answer by ds5 · Oct 19, 2017 at 08:16 PM

Hi, I´m with the same problem now. So how could I set the controller before run the scene.

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 SepraB · Oct 20, 2017 at 02:31 AM 0
Share

It has been a long time since that issue and I guess the problem still does not have any solution.

avatar image
0

Answer by harko12 · Jan 30, 2019 at 06:57 AM

Hi there. I'm not sure if anybody is still having trouble with this. I think I have accomplished what what it was you were trying to do. Basically, I set up an Animator on my character, and then a set of SerializedObject's to hold the different RuntimeAnimiatorControllers I wanted to switch to. Then, at the appropriate time, I ran this basic code:

 RuntimeAnimatorcontroller motionAnimator; // set up previously
 // store the previous controller
 originalAnimator = myController.myAnim.runtimeAnimatorController;
 // change the runtimeAnimatorController on the Animator to the new controller
 myController.myAnim.runtimeAnimatorController = motionAnimator;
 

That all worked for me as far as changing controllers when I wanted it to. However, once I got it to work, the problem then became smoothly animating between controllers. it got very jumpy. I'm now in the process of refactoring all of that out, and auto generating my AnimatorController based on some chosen sub state machines. But the switching did work.

Comment
Add comment · 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

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

89 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

Related Questions

BasicFPS controller "Can not be loaded" 0 Answers

After swiping down, I want player to slide once, instead of infinitely looping his animation, script attached below 0 Answers

have an error that i don't know how to fix 1 Answer

HELP,Watched tutorial https://www.youtube.com/watch?v=Xnyb2f6Qqzg 1 Answer

Script Variable not transfering 0 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