【发布时间】:2016-07-28 02:27:23
【问题描述】:
我正在尝试根据键输入使用脚本更改角色动画,但 Unity 似乎只播放默认的“站立空闲”动画,偶尔切换到“蹲下空闲”,是否有不同的方式来处理动画还是我只是做错了脚本?这是我目前的脚本
using UnityEngine;
using System.Collections;
public class CharacterControl : MonoBehaviour {
private Animator animator;
public bool crouched;
private string sc;
// Use this for initialization
void Start () {
animator = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
if (crouched == true) {
sc = "crouch";
} else {
sc = "standing";
}
animator.Play (sc + "_idle");
if (Input.GetButton ("Fire3")) {
if (crouched == false) {
crouched = true;
} else {
crouched = false;
}
}
}
}
【问题讨论】: