Animation Unity 5.1动画师控制器未转换
我已经创建了一个Animation Unity 5.1动画师控制器未转换,animation,unity3d,Animation,Unity3d,我已经创建了一个动画师控制器(称为播放器),并将其分配给我的人形化身的动画师字段,以及具有适当过渡的简单动画状态。请参阅所附的两张图片 我在我的阿凡达游戏对象上附加了一个包含以下代码的脚本,但我想知道我遗漏了什么或做错了什么,从Idle到Walk的转换没有发生,即使我可以看到speed变量在我按下W时会增加 有人能帮我理解这个问题吗 using UnityEngine; using System.Collections; public class CharAnim : MonoBehaviou
动画师控制器
(称为播放器
),并将其分配给我的人形化身的动画师
字段,以及具有适当过渡的简单动画状态。请参阅所附的两张图片
我在我的阿凡达游戏对象上附加了一个包含以下代码的脚本,但我想知道我遗漏了什么或做错了什么,从Idle
到Walk
的转换没有发生,即使我可以看到speed
变量在我按下W
时会增加
有人能帮我理解这个问题吗
using UnityEngine;
using System.Collections;
public class CharAnim : MonoBehaviour
{
private Animator animator;
float speed;
void Start()
{
animator = GetComponent<Animator>();
}
void Update()
{
animator.SetFloat( "speed", Input.GetAxis("Vertical") );
if ( Input.GetKeyDown( KeyCode.W ) && ( speed > 0.5f ) )
{
animator.SetTrigger("Walk");
}
else
{
animator.SetTrigger("Idle");
}
}
}
使用UnityEngine;
使用系统集合;
公共类特征:单一行为
{
私人动画师;
浮动速度;
void Start()
{
animator=GetComponent
代码中的问题是,animator.SetTrigger(“Walk”);
在按下键时在单个帧中被调用,而animator.SetTrigger(“Idle”);
在其余帧中被调用
尝试将Input.GetKeyDown(KeyCode.W)
更改为Input.GetKey(KeyCode.W)
。前者仅在按下键的瞬间返回true一次,而后者在松开键之前返回true。类似于:
void Update ()
{
if(Input.GetKey(KeyCode.W))
{
animator.SetTrigger("Walk");
}
else
animator.SetTrigger("Idle");
}
另一方面,您不需要使用Animator
中的speed
变量来触发行走动画,因为您已经在使用W
进行此操作
空闲->步行
步行->空闲
{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
}
其他的
设置触发器(“空闲”);
}{
if(Input.GetKey(KeyCode.W))
{
设置触发器(“行走”);
谢谢尼米什。我做了你建议的更改,但是