I have the following code below, but Unity keeps producing this error as the game runs, every frame:
NullReferenceException: Object reference not set to an instance of an object
GeneralPhysics.Update () (at Assets/Scripts/Managers/GeneralPhysics.cs:11)
Here is my code:
using UnityEngine;
using System.Collections;
public class GeneralPhysics : MonoBehaviour {
private tk2dTileMap tileMap;
private int tileId;
void Update()
{
Vector3 testLocation = new Vector3(transform.position.x,transform.position.y,0f);
tileId = tileMap.GetTileIdAtPosition(testLocation,9);
}
}
How do I get it to stop making this error? Sorry if it's a noob question, I'm still learning C#.