首页 > 解决方案 > 如何在非运动学的刚体上使用动画?

问题描述

我没有动画经验,我正在尝试在我使用 AddForce 移动的角色上插入动画。如果我插入步行动画,动画会移动刚体,她决定它移动的速度。如果在动画师中我不应用“Root Motion”,则动画不会移动角色,我可以使用 AddForce 移动它,但动画与角色的速度不同步。如何将动画的速度与我移动刚体的速度联系起来。我希望如果我改变我用来移动角色的“速度”参数,动画的速度也会改变,始终保持同步。

标签: unity3danimationrigid-bodies

解决方案


我认为这对你有用:

float speed;//you must set this value with rigidbody's velocity
Animator animator;
void Start()
{
    animator=getComponent<Animator>();
}

void Update()
{
    animator.speed=speed;//you can change it with speed/10 to make more realistic
}

推荐阅读