I'm trying to make my character walk in one animation and stand in the other.
In Animator
, I created a parameter of type float
walk to do the exchange control between the animations as shown in the image below.
Andassignthefollowingconditionstothearrows:
*walk>0.1goestothecharacter;
*walk<0.1goestothecharacterStop;
Exampleofoneofthearrows:
My code looks 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's something related to the Unity version but I do not know what it might be, I'm doing this game by following this tutorial
link
My Unity is 5.3.1f1 and the one in the tutorial is 4.3.2f1
In% example, there is no Entry shown in the first image.
UnassignedReferenceException: The variable animation of Controls has not been assigned. You probably need to assign variable animation of the Controls script in the inspector. UnityEngine.Animator.SetFloat (System.String name, Single value) Controls.Update () (at Assets / Assets / Scripts / Controls.js: 17)