6
I’m trying to get my character to walk in one Animation and stand in the other.
In Animator
, created a parameter of type float
walk to make the exchange control between the animations as shown in the image below.
And assigns in the arrows the following conditions:
*walk > 0.1 goes to character;
*walk < 0.1 goes to the personStop;
My code is like this:
#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;
//O ERRO OCORRE AQUI!!!!!_________________________________________
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);
}
}
Maybe it may be something related to the version of Unity but I don’t know what it may be, I’m doing this game following this tutorial
https://www.youtube.com/watch?v=PDuqGIB8j7E
My Unity is 5.3.1f1 and the tutorial is 4.3.2f1
In the Animator
of the example, there is no Entry shown in the first image.
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) Controls.Update() (at Assets/Assets/Scripts/Controles.js:17)