Controles的变量animacao没有赋值
The variable animacao of Controles has not been assigned
我试图让我的角色在一个 animation
中行走,在另一个 animation
中静止不动。
在Animator
中,我创建了一个float
和dar类型的参数来控制动画之间的交换,如下图所示。
并为箭头分配以下条件:
*andar > 0.1 = 人物;
*andar < 0.1 = personagemStop;
箭头之一的示例:
我的javascript代码:
#pragma strict
var speed : float;
var personagem : GameObject;
var animacao : Animator;
function Start () {
speed = 2;
}
function Update () {
transform.position.x += Input.GetAxis("Horizontal") * speed * Time.deltaTime;
//THE ERROR OCCURS IN "andar"!!!!!_________________________________________
animacao.SetFloat("andar",Mathf.Abs(Input.GetAxis("Horizontal")));
//________________________________________________________________
if(Input.GetAxis("Horizontal") < 0){
personagem.gameObject.transform.eulerAngles = Vector2(0,180);
}
else if(Input.GetAxis("Horizontal") > 0){
personagem.gameObject.transform.eulerAngles = Vector2(0,0);
}
}
可能与Unity版本
有关
我正在学习本教程。
https://www.youtube.com/watch?v=PDuqGIB8j7E
我的 Unity 版本 = 5.3.1f1
Unity教程版本=4.3.2f1
错误:
UnassignedReferenceException: The variable animacao of Controles has
not been assigned. You probably need to assign the animacao variable
of the Controles script in the inspector.
UnityEngine.Animator.SetFloat (System.String name, Single value)
Controles.Update () (at Assets/Assets/Scripts/Controles.js:17)
答案很简单,您需要将包含动画师的对象拖放到检查器中脚本的 animacao
字段中。否则,您的脚本不知道使用哪个动画师。
其实视频里没有显示,5:28左右黑屏的时候已经做了。
我试图让我的角色在一个 animation
中行走,在另一个 animation
中静止不动。
在Animator
中,我创建了一个float
和dar类型的参数来控制动画之间的交换,如下图所示。
并为箭头分配以下条件:
*andar > 0.1 = 人物;
*andar < 0.1 = personagemStop;
箭头之一的示例:
我的javascript代码:
#pragma strict
var speed : float;
var personagem : GameObject;
var animacao : Animator;
function Start () {
speed = 2;
}
function Update () {
transform.position.x += Input.GetAxis("Horizontal") * speed * Time.deltaTime;
//THE ERROR OCCURS IN "andar"!!!!!_________________________________________
animacao.SetFloat("andar",Mathf.Abs(Input.GetAxis("Horizontal")));
//________________________________________________________________
if(Input.GetAxis("Horizontal") < 0){
personagem.gameObject.transform.eulerAngles = Vector2(0,180);
}
else if(Input.GetAxis("Horizontal") > 0){
personagem.gameObject.transform.eulerAngles = Vector2(0,0);
}
}
可能与Unity版本
有关我正在学习本教程。
https://www.youtube.com/watch?v=PDuqGIB8j7E
我的 Unity 版本 = 5.3.1f1
Unity教程版本=4.3.2f1
错误:
UnassignedReferenceException: The variable animacao of Controles has not been assigned. You probably need to assign the animacao variable of the Controles script in the inspector. UnityEngine.Animator.SetFloat (System.String name, Single value) Controles.Update () (at Assets/Assets/Scripts/Controles.js:17)
答案很简单,您需要将包含动画师的对象拖放到检查器中脚本的 animacao
字段中。否则,您的脚本不知道使用哪个动画师。
其实视频里没有显示,5:28左右黑屏的时候已经做了。