Search Unity

Animator not animating properties.

Discussion in 'Animation' started by Kevin_OBrien, Sep 18, 2021.

  1. Kevin_OBrien

    Kevin_OBrien

    Joined:
    Feb 18, 2015
    Posts:
    10
    I'm trying to set up fps hand animations inside of unity. My approach is to use a generic rig where I attach the gun to the arms, make the animation, then delete the gun from the prefab so then the gun property is "missing" but that's irrelevant since the animation will only be played in game when the player has that gun hence the hierarchy will be the same as when the animation was made.

    I've tested this and the animator IS able to find the gun, I can double click on the property and it will become highlighted in the hierarchy. I can also press play on the animation timeline and it will animate the gun, but it DOESN'T work in game. The gun will simply float in midair unanimated. Why is this happening? Am I misinterpreting something?

     
  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    244
    Hey,

    This is intended behavior. I'm not exactly sure what's going on behind the scenes, but basically Unity doesn't generate the animation data for missing objects. The reason the gun doesn't animate is because there's no data to animate it at runtime.

    You can use
    Animator.Rebind()
    to "restart" the animator controller and have it generate the animation data again at runtime, which would then include the data for any attached objects. The downside to this is that your animator controller will reset back to its initial state, so it's not very smooth.
     
unityunity