It looks like I can't assign my camera like usual anymore.

Hello! A few months ago, I made this thread here:


That worked perfectly at the time, but I don't think the solution works in the my version of unity anymore. For starters, the original camera's API is now obsolete, so the code here:

var cameraController = camera.GetComponent<CameraController>();

gets automatically updated to a different line of code in my version of unity. I don't know if that's the cause of my problem, but regardless, my code no longer assigns the camera to my player after the player selection screen, and I don't know how to fix it. Any ideas?
 
You may have previously had the version of Unity where camera would return the current main camera. You may instead need to use Camera.main, i.e. var cameraController = Camera.main.GetComponent<CameraController>();
 
You may have previously had the version of Unity where camera would return the current main camera. You may instead need to use Camera.main, i.e. var cameraController = Camera.main.GetComponent<CameraController>();

Unfortunately, I haven't been able to get it to work. Originally, I had a separate script on "Game Manager" game object which would handle the camera assigning. Although I'm using most of the same code (with the camera code modified), its not assigning the camera to my character when he spawns.

What does work is me turning off the camera game object, and activating it after the game starts.
 
You mentioned that some code got automatically changed/updated - what did it change to? It could also be some difference in script execution order, if you were previously trying to assign in Awake/Start, but hard to know without seeing the exact places you're using this code etc.

In any case glad you figured out a solution!
 
Top