How to prefab animations in Unity?

时间:2019-04-17 02:26:45

标签: unity3d

created a prefab for door and added the prefab doors to the scene. This prefab door has an animator. The problem is when I try to change the animator x,y,z position on the second door in the scene it changes the first door.

I tried duplicating the doors and changing the position x y z but it changed the animator for the first door.

I just have a script that play the animator.

The expected result should be that I can drag and drop doors as needed without creating individual animators for each door. It looks like i need to create animators per door there is and also this probably will require me to create new scripts per each door. It seems awkward since I should be able to add doors and just chaning the position x y z in the animator.

1 个答案:

答案 0 :(得分:1)

问题在于他们的Animator组件使用相同的AnimatorController资产,而该资产使用了某些AnimationClip资产引用作为其状态。

我不知道是否有更简单的方法可以实现,但是我会执行以下操作:

  • 对于您想要的内容,您必须复制AnimatorController资产(CTRL + D)以及要更改的AnimationClip资产。

  • 然后在克隆的AnimatorController中单击要更改的相应状态,然后在检查器引用中单击相应的克隆的AnimationClip

  • 现在,您拥有使用不同的AnimatorController的{​​{1}}的副本,但具有相同的状态,传统等,因此您可以分别编辑动画和控制器。

    < / li>
  • 最后在AnimationClip组件中为每个预制件引用Animator

现在剩下的问题可能是,将来,如果您更改状态,转换尤其是参数,则必须分别在两个AnimatorController资产中进行此操作。

相关问题