Getting a null exception error message

Just finished lecture 79 and it plays fine - the player falls from the sky , sails through water and stops on the platform. However I’m getting the following null exception message:

I’m not currently running any scripts. I’ve tried running the game with various elements disabled but I still get the same message. I understand from an earlier thread that this arises because an element is being referred to but it has not been instantiated. Any tips as to what I’m looking for in the context of being where the game is at the end of this lecture?

BTW I’m also getting an intermittent error message “Screen position out of view frustum” . Having googled this it seems to be a buggy issue with most posts simply saying ignore it or restart - anyone know if I should be doing something more proactive than just keeping my fingers crossed?

Thanks,

K

Hi K,

Have you already tried to restart Unity?

Regarding the ‘Screen position out of view frustum’ error, click the Main Camera game object. Make sure the orthographic size of the Camera component is not set to 0.

Regarding the other error, do you remember when it appeared the first time and what you did right before it appeared?

OK - confused! I restarted Unity as suggested and sure enough the null reference error goes away. But I tried restarting earlier and it stayed. Hum? Anyway - currently gone.

Regarding the camera - size = 5, z co-ord = -10. However I’ve noticed that the error goes if I set the projection to perspective. Also, do not know if this helpful, but the error (with projection set to orthographic) only appears after I have stopped playing.

K

Which version of Unity do you use? There is a chance that you are experiencing a bug in your editor.

v 2023.2.5f1

It is worth emphasizing that it seems to be working in play-mode. It might be that I can simply ignore this?

K

According to the NullReferenceException error message, the error seems to refer to UnityEditor, so it might be that the issue is limited to the editor and won’t affect your game. Please go to Window > Layouts and select “Default”. If you created your own layout, remove that, select “Default”, rearrange the windows and save it again. In some cases, the error is caused by the layout.

Regarding the problem with the screen position, if your game works as expected at runtime, you may ignore the problem for now.

However, I would recommend to make a backup of your project folder by duplicating it. Save the duplicated folder somewhere else, maybe on an USB stick. To save some free space, you could delete the Library and Temp folders in the backup folder. Then proceed with developing your game (not with the backup).

Did as suggested and reverted to the default layout - before I had anchored various screens to copy Rick’s screen (animator, tile palette etc). Now I do not get any error messages - including the camera issue, which must be a coincidence?

Thanks for your help,

K

Awesome! I didn’t expect the camera issue to get solved automatically. Maybe you are right, and there is indeed an unexpected connection between the editor and the camera. That’s not something we could fix, though, because it would be part of the Unity engine itself. If the error messages are gone, consider the problem solved. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms