Good afternoon, I'm having a hard time understanding what this error is, I still have only 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 the project runs runs
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 variable player 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)