The variable animation of Controls has not been assigned

6

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)

    
asked by anonymous 24.12.2016 / 23:24

1 answer

0

I found the problem.

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

In fact, he forgot to show something, on the object when we added the javaScript code to it, we should inform personagem and animação as shown in the image. If you do not, the error mentioned in the question occurs.

Animation-AnimatoristheAnimatorofthefirstimageofthequestion.Character-characteristheparent'schild,wherespritesareexchanged.

    
30.12.2016 / 23:13