The variable animacao of Controles has not been Assigned

Asked

Viewed 265 times

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.

inserir a descrição da imagem aqui


And assigns in the arrows the following conditions:

*walk > 0.1 goes to character;
*walk < 0.1 goes to the personStop;

Example of one of the arrows:
inserir a descrição da imagem aqui


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)

1 answer

0


I found the problem.

In the tutorial link mentioned in the question, in approximately 5:28 of the video an error occurs, hence comes a black screen saying it was solved but does not explain exactly what happened.

In fact, he forgot to show something, in the object when we add the Java code to it, we must inform the personagem and the animação as shown in the image. If you do not do this, the error mentioned in the question.

inserir a descrição da imagem aqui


Animacao - character (Animator) is the Animator of the first picture of the question.
Character - character is the son of principal, where sprites exchange occur.

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.