it seems like your camera does not have a target if you instantiate the player. when the player was not a prefab but calmly sitting in the hierarchy there was no problem because (i assume) you dragged the player-object into the corresponding camera-target slot in the inspector. all good.
but as soon as you remove the player from the hierarchy and make him a prefab. your camera does not know who to follow even though a player might be spawned later on.
to solve this little riddle you have to tell your camera to look for a player if it has no target to follow. dumb lazy camera.
you might try to do the following:
select your player prefab - top line on inspector dropdown menu “TAG” - select “Player”
add this to the update function of your camera
if (!target) {
target = GameObject.FindGameObjectWithTag("Player").transform;
}
add this to the start function of your camera
if (!target) {
target = GameObject.FindGameObjectWithTag("Player").transform;
}
Thank you so much!!! I was having this error and couldn’t figure out how to fix it, then I read this and applied what you said; it was fixed instantly! Thank you!