Accessed none when changing level

I am having an issue where I have Time Instance which relates to my sky.

I faced this error when I was changing my level, if I play directly on the level on the editor (not from the menu level) there are no errors, it happens when I play from the menu level and change to another level.

The problem occurs when I set up a UI that can change the Time variables, it carries out the variables’ value on the other level and the level is playable however this error keeps pop out after I stop the editor.

it’s accessing an object that gets cleaned during the level transition.

a patch is checking if the object “isValid” inside that function.
another is to stop that function, and restart after level change. which seems to be happening on tick or on timer.
a cleaner approach will not be keeping an ui that persists across level.

to persist data across level you might want to consider the game instance.

1 Like

I did create a game instance with a save and load system and save the time variables that i change using UI. Should i save all time variables?

Hey there @Faey01! Nande is correct, and your approach to saving the time when changing level is one way to do it, though if you just have your time processing inside of levels and only pass it to the game instance for saving before level changing and loading the time from it once when the next level is opened it would save you a significant amount of effort.

2 Likes

Thank you for your clarify, I might need to rework the saving and loading system on my side to improve it and avoid the error.

As i am just realizing my time instance keep spawning themselves (become new time instance) at other levels which may cause the error. I am using plugin for my time and sky system, so i might need to deep further to understand this error.

1 Like