unity动画怎么控制,就是比如说人物按住w执行移动动画

unity动画怎么控制,就是比如说人物按住w执行移动动画,不按之后就停止

放在update里监听:
if (Input.GetKey(KeyCode.W)) {//执行移动动画如,animatio.Play()}
松开w键
else if (Input.GetKeyUp(KeyCode.W))
{
Debug.Log("松开 w键");
//停止动画
}