Hello!
I'm new to Unity . I make a 2D game. When trying to track where to click on the "playing field" I got the following error in the console:
NullReferenceException: Object Reference. Select.Update () (at Assets / Scripts / Select.cs: 23)
The method in which this occurs:
void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast (ray, out hit, 100)) { Debug.Log ("Hit something!"); } else { Debug.Log ("No Hit something!"); } } 23 line:
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Can you set me on the right path? And I will be grateful if you advise literature for development in scripting on Unity .