I’m an experienced programmer learning Unity for the first time. I know this is the most basic and common error for the newbies. I think I have got it right but it still produces this error. What am I doing wrong?
UnassignedReferenceException: The variable player of ‘GameManager’ has not been assigned.
You probably need to assign the player variable of the GameManager script in the inspector.
I think the following screenshot provides everything needed.
This screenshot has nothing to do with your question (or at least a little :)). In your GameManager script, you have two public variables: cam and player. First one is initialized inside Start method, while the second one is not initialized in your script, so it should be set in the inspector.
You have to select the object to which GameManager script is attached (Hierarchy window), and then in the inspector you’ll see that in the script component there is player variable set to ‘None’. Click your prefab folder and drag the Player prefab to this field.