Problem with the Animator

Hello Friends…

I am currently in the tutorial of Code Monkey and now I have a problem. Yesterday I closed Unity and everything was still okay. Today I start Unity and have this error.

NullReferenceException: Object reference not set to an instance of an object
PlayerAnimator.Update () (at Assets/Scripts/PlayerAnimator.cs:21)

Whenever I add this code

animator.SetBool(IS_WALKING, player.IsWalking());

I hope someone can help me here.

Here is the Code that the Error Shows me

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerAnimator : MonoBehaviour
{
private const string IS_WALKING = “IsWalking”;

[SerializeField] private Player player;

private Animator animator;

private void Awake()
{
animator = GetComponent();
}

private void Update()
{
animator.SetBool(IS_WALKING, player.IsWalking());
}

}

9691025--1382747--Error1.png

Dont post pictures of code

but clearly you arent understanding what codemonkey has said cos that script requires a player, and an animator… You didnt fill in player and you removed the animator… how on earth did you expect it to work

Hay Bugfinder, i will remove the Picture of the code.

I have the Animator, and the Player. The Player also moves and the Head Animation Works. Only the Walking Animation wont Work. Everything is okay with the Logic and Code so far only this Error is stopping me.

no code tags are as bad as pictures :stuck_out_tongue:

anyway you havent grasped the point of this code, go back and watch the tutorial again.

clearly shows
YOU have not assigned the player, it says none
YOU removed the animator, which it looks for in the code to do stuff…
ergo, it will not work

Plus, debug and prove to yourself what it says is null.

Hey BugFinder

Thank you very much for you help, i dont know how i could miss that part. It works now. Thank you very much!