So does anyone know why in the lecture, the below code works in the update method but mine kept throwing a null reference exception on the NetworkClient.connection.identity?
I’m working in Unity 2020.2.2
if (player == null)
{
player = NetworkClient.connection.identity.GetComponent<RTSPlayer>();
}
My work around to get it to work was add it in the LateUpdate method and add the AND check,
private void LateUpdate()
{
if (player == null && NetworkClient.connection.identity != null)
{
player = NetworkClient.connection.identity.GetComponent<RTSPlayer>();
}
}