你好,我有这个脚本,并在无效更新无关紧要什么是第一次倒退或跑起来,它总是让动画师播放动画向后走或运行播放动画的一半或完整的方式,它在没有被调用的情况下播放闲置状态的一部分,这意味着你的手指仍然在按钮上,所以它仍然必须反复向前/向后播放动画。 这里是代码:Unity角色控制器脚本和动画师
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerController : MonoBehaviour {
public float moveSpeed = 10f;
public float turnSpeed = 50f;
Animator anim;
// Use this for initialization
void Start() {
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update() {
if (Input.GetKey (KeyCode.S)) {
anim.SetBool ("isIdle", false);
anim.SetBool ("isWalkingBack", true);
transform.Translate (-Vector3.forward * moveSpeed * Time.deltaTime);
}
else
{
anim.SetBool ("isIdle", true);
anim.SetBool ("isWalkingBack", false);
}
if (Input.GetKey (KeyCode.W)) {
anim.SetBool ("isRunning", true);
anim.SetBool ("isIdle", false);
transform.Translate (Vector3.forward * moveSpeed * Time.deltaTime);
}
else
{
anim.SetBool ("isRunning", false);
anim.SetBool ("isIdle", true);
}
}
}
`
它仍然做同样的事情 – Ghigh
http://imgur.com/a/AemiZ – Ghigh
好的nvm thanks ^^ – Ghigh