Problem with my Unity game

I have an assignment to make a chess game in unity, when i enter play mode and try selecting a figure i get 2 different errors.

When i attempt to select a pawn:

Pawn NullReferenceException: Object reference not set to an instance of an object MoveManager.JelEnemy (Tile tile) (at Assets/Scripts/MoveManager.cs:215) MoveManager.Provjeri_Spremi (UnityEngine.Vector2 move) (at Assets/Scripts/MoveManager.cs:198) MoveManager.GenerateMove (System.Int32 limit, UnityEngine.Vector2 direction) (at Assets/Scripts/MoveManager.cs:192) MoveManager.PAWNMoves () (at Assets/Scripts/MoveManager.cs:151) MoveManager.GetMoves (Piece piece, UnityEngine.Vector2 position) (at Assets/Scripts/MoveManager.cs:40) Piece.OnMouseOver () (at Assets/Scripts/Piece.cs:62) UnityEngine.SendMouseEvents:smile:oSendMouseEvents(Int32)

When i attempt to select other figures:

Other Figures NullReferenceException: Object reference not set to an instance of an object MoveManager.JelEnemy (Tile tile) (at Assets/Scripts/MoveManager.cs:215) MoveManager.Provjeri_Spremi (UnityEngine.Vector2 move) (at Assets/Scripts/MoveManager.cs:198) MoveManager.GenerateMove (System.Int32 limit, UnityEngine.Vector2 direction) (at Assets/Scripts/MoveManager.cs:192) MoveManager.PAWNMoves () (at Assets/Scripts/MoveManager.cs:151) MoveManager.GetMoves (Piece piece, UnityEngine.Vector2 position) (at Assets/Scripts/MoveManager.cs:40) Piece.OnMouseOver () (at Assets/Scripts/Piece.cs:62) UnityEngine.SendMouseEvents:smile:oSendMouseEvents(Int32)

@Kurt-Dekker we need your link :stuck_out_tongue:

2 Likes

Some notes on how to fix a NullReferenceException error in Unity3D

  • also known as: Unassigned Reference Exception
  • also known as: Missing Reference Exception

http://plbm.com/?p=221

The basic steps outlined above are:

  • Identify what is null
  • Identify why it is null
  • Fix that.

Expect to see this error a LOT. It’s easily the most common thing to do when working. Learn how to fix it rapidly. It’s easy. See the above link for more tips.

2 Likes

Thank you for helping il check it out