2
Good afternoon I’m having a hard time understanding what that mistake would be I still have a few days in the programming world someone can help me
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public float Velocidade;
public Transform player;
private Animator animator;
// Use this for initialization
void Start () {
animator = player.GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
Movimentar();
}
void Movimentar ()
{
animator.SetFloat ("Run", Mathf.Abs (Input.GetAxis ("Horizontal")));
if (Input.GetAxisRaw ("Horizontal") > 0) {
transform.Translate (Vector2.right * Velocidade * Time.deltaTime);
transform.eulerAngles = new Vector2 (0,0);
}
if(Input.GetAxisRaw ("Horizontal") < 0) {
transform.Translate(Vector2.right * Velocidade * Time.deltaTime);
transform.eulerAngles = new Vector2(0,180);
}
}
}
the error after trying executes the project
Nullreferenceexception: Object Reference not set to an instance of an Object Player.Move () (at Assets/Scripts/Player.Cs:22) Player.Update() (at Assets/Scripts/Player.Cs:18)
Unassignedreferenceexception: The variable player of Player has not been Assigned. You probably need to assign the player variable of the Player script in the inspector. Unityengine.Component.Getcomponent[Animator] () (at C:/buildslave/Unity/build/artifacts/generated/common/Runtime/Unityenginecomponent.gen.Cs:45) Player.Start() (at Assets/Scripts/Player.Cs:13)