• 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
Question by CaioRosisca · Mar 14, 2017 at 03:08 PM · animationprefabanimatorruntime

Runtime instantiated prefab doesn't animate

I'm trying to make my character instantiate it's model in runtime (because I have different skins for it). What I have now is all the code, colliders and animator in a parent gameobject and I'm trying to instantiate the model related to the chosen skin in runtime.

For some reason the model doesn't animate when I do that.

If I put the same model prefab inside the character and instantiate it as one it works without any problem.

The visual prefab does not have any components on it.

alt text

As shown in the image, "Character_WithDefaultSkinModel" works perfectly, but when Instantiating Character_empty and then instantiating "Character_DefaultSkinModel" and setting it's parent to the Chracter_empty, the model doesn't animate.

EDIT:

I just realised that acessing the Animator and enabling then disabling the "Apply Root Motion" checkbox the character starts animating again.

It's like the component needs a reset, does anyone have an idea why? and how to force it properly

problem.png (6.0 kB)
Comment

People who like this

0 Show 0
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
Best Answer

Answer by CaioRosisca · Mar 14, 2017 at 06:30 PM

I just solved it, all I needed to do was to call Animator.Rebind();

Comment
lgarczyn
koptehe
imrankhanswati
pkake2000
Ozcanolguner
baktubak
akaBase
Art-Mouse

People who like this

8 Show 4 · 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 hexagonius · Mar 14, 2017 at 09:51 PM 1
Share

ah cool nice to know

avatar image imrankhanswati · Oct 10, 2019 at 09:30 AM 0
Share

Great man... This is awesome work like a charm. Thanks a lot...

avatar image ISAKUPOLY · May 25, 2021 at 06:25 PM 1
Share

Hey CiaoRosisca,

i'm not sure if you are still active, but I wanted to ask you where did you put the "Animator.Rebind()" exactly? You have your script for the animation in you parent object, right?

Currently i'm at the problem that I can instantiate a Prefab as a child, but (while the already instatiated object works perfectly finde) the new instantiated is not using the animations (the movement script including the animation scripts are all in the Parent).

avatar image baktubak · Dec 08, 2021 at 10:21 PM 0
Share

Thank you so much! I was having this exact problem. I was spawning in an object using instantiate and then immediately triggering the animator to play, but it wasn't working until I added rebind! YAY.

avatar image

Answer by hexagonius · Mar 14, 2017 at 06:12 PM

might not be that easy, but you definitely missed a step:

https://docs.unity3d.com/ScriptReference/Animator-avatar.html

Comment

People who like this

0 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 CaioRosisca · Mar 14, 2017 at 06:16 PM 0
Share

They both use the same avatar

avatar image

Answer by lgarczyn · Mar 14, 2017 at 06:12 PM

You might just be calling Instantiate() on a gameobject in your scene rather than on a prefab (gameobject in your asset folder).

Comment

People who like this

0 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 CaioRosisca · Mar 14, 2017 at 06:17 PM 0
Share

I'm loading it from resources folder

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

161 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

Related Questions

Attaching a child object to a parent object that animates it in runtime 0 Answers

Animator not animating a runtime instantiated child 0 Answers

Prefab animation only plays on first instance 1 Answer

Animation questions (newbie) 1 Answer

Setting animator parameter on a single instance of a prefab sets the parameter for all instances 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