Hi, I’ve already had this problem before, then its solved somehow, now its happening again. After I got killed and press the button “again” nothing happens, my game freezes. I checked the code, its fine, I have only one camera.
Hi CJ89,
Have you already tried to add Debug.Logs to your code to see what is going on during runtime? Do you call DontDestroyOnLoad somewhere in your code?
I don’t know how to do that
What exactly don’t you know?
Have you already rewatched the videos at least one more time? Maybe something is missing in your project.
I rewatched these videos many times, and nothing.
Something is missing indeed, but i don’t know what exactly, that’s why I’m asking how to fix it
I don’t know how to use DontDestroyOnLoad and Debug.Login in this case
Did you follow the previous sections? Debug.Logs were taughed and often used.
You wrote that the game freezed. How do you know that it freezed? If it freezed, no messages would get logged into your console anymore. That’s something you could test with a Debug.Log in an Update method. If Unity freezed, there is very likely an endless loop involved. Maybe the screen gets enabled over and over again.
Another thing you could do is to log the instance id of the camera(s) into your console or the number of cameras in the scene with FindObjectsOfType. Since you click a button to have your program do something, you could check these things on button click.
If you don’t know how to use DontDestroyOnLoad, you probably did not use it anywhere in your code. In that case, my comment regarding DontDestroyOnLoad is irrelevant for you.
Yes, Debug.Log is offten used, but its never said how and where to type it to check why my camera view is frozen after I got killed, but the scene view is fine as you can see on the video. My question is how to fix it?
That’s what we are trying to figure out. We still do not know what the underlying problem is. As long as we do not know it, it is impossible to fix it. With Debug.Logs, you could analyse the problem further. In my previous answer, I suggested to check the number of cameras and the instance id(s) of the camera(s) in your scene on button click. This means that you could add a Debug.Log to the method which gets called by the “Play Again” button.
Have you already tried that? If so, what was the result?
there is only one camera. as for Deebug, could you exactly tell my what to type and where? I’m not good at coding, sorry
You could, for example, write a quick Test script. In its Start method:
Debug.Log(Time.frameCount + " --- Camera id: " + gameObject.GetInstanceID());
You assign that script to your camera game object.
Play your game. Once the problem occurs, check your console. If you see two different instance ids, you have more than one camera object.