NullReferenceException(CS) object reference not set to an instance of an object?

Hi, I keep getting the error and it is saying that the object reference is not set to an instance of an object. I have set up my tags carefully and I believe it is something wrong with my code on line 36, including the error in my method. Here is the code. The code is from the PlayerMovement script in the project Stealth. Thank you.


using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour
	public AudioClip shoutingClip;      // Audio clip of the player shouting.
	public float turnSmoothing = 15f;   // A smoothing value for turning the player.
	public float speedDampTime = 0.1f;  // The damping for the speed parameter
	private Animator anim;              // Reference to the animator component.
	private HashIDs hash;               // Reference to the HashIDs.
	void Awake ()
		anim = GetComponent<Animator>();
		hash = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<HashIDs>();

		anim.SetLayerWeight(1, 1f);
	void FixedUpdate ()
		float h = Input.GetAxis("Horizontal");
		float v = Input.GetAxis("Vertical");
		bool sneak = Input.GetButton("Sneak");
		MovementManagement(h, v, sneak);

	void MovementManagement (float horizontal, float vertical, bool sneaking)
		anim.SetBool(hash.sneakingBool, sneaking);

		if(horizontal != 0f || vertical != 0f)

			Rotating(horizontal, vertical);
			anim.SetFloat(hash.speedFloat, 5.5f, speedDampTime, Time.deltaTime);
			// Otherwise set the speed parameter to 0.
			anim.SetFloat(hash.speedFloat, 0);
	void Rotating (float horizontal, float vertical)
		Vector3 targetDirection = new Vector3(horizontal, 0f, vertical);

		Quaternion targetRotation = Quaternion.LookRotation(targetDirection, Vector3.up);

		Quaternion newRotation = Quaternion.Lerp(rigidbody.rotation, targetRotation, turnSmoothing * Time.deltaTime);




using UnityEngine;
using System.Collections;

public class HashIDs : MonoBehaviour {
	public int locomotionState;
	public int speedFloat;
	public int sneakingBool;

	void Awake(){
		locomotionState = Animator.StringToHash ("Base Layer.Locomotion");
		speedFloat = Animator.StringToHash("Speed");
		sneakingBool = Animator.StringToHash("Sneaking");




using UnityEngine;
using System.Collections;

public class Tags : MonoBehaviour {

	public const string player = "Player";
	public const string gameController = "GameController";
	public const string fader = "Fader";


check your [HashIDs hash] field was successfully allocated in Awake? that wasn’t null?

and next is less probability, check your [Animator anim] field was successfully allocated with GetComponent().

  1. i think your problem is in PlayerAnimator check the done folder and copy this file to your project folder and then rename it to your file name.
  2. under gameController object in hierarchy go to secondryMusic and change tag to untagged.