Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Animator doesn't animate transform added on runtime.

Discussion in 'Animation' started by iv2b, Jan 25, 2019.

  1. iv2b

    iv2b

    Joined:
    Aug 2, 2018
    Posts:
    25
    I'm working on reloading/pickup/juggle animations and i'm trying to make a simple proof of concept animation.
    Using umotion i've animated my player character to pick up an item, throw it upwards, then catch it.
    The item i'm picking up is a cube and it's a child of the character's root bone (hips), allowing me to animate the cube's transform during the animation (otherwise the throw would be impossible without IK shenanigans).

    If i play the animation with the cube already a child of the character's hips then the animation plays perfectly.
    However, if i instantiate a cube (with the same name as the cube used when making the animation) and set it as a child of hips, the cube will not be animated.

    If i manually (as in using the editor, not through script) change the animator's update mode (between normal, animate physics and unscaled time) then the issue is solved and the cube will be animated as expected.

    I'd however really need a way to do the above through script, i've even tried changing the update mode every frame and nothing happens.

    Does anyone know a solution?

    *edit*

    Toggling root motion through the editor works as well, nothing happens when done through script.

    *edit*

    Animator.rebind();
    worked
     
    Last edited: Jan 25, 2019
    Treegemmer likes this.