Page 1 of 1

Class object that is persistent throughout every level?

Posted: Tue Aug 28, 2018 1:08 am
by CHADALAK1
Hello Community!

I was curious if there as a sort of singleton object in CE that is always persistent throughout the game (UE4 = GameInstance, Unity=DontDestroyOnLoad)? I was searching for it in the docs and i really cannot find any leads.

Re: Class object that is persistent throughout every level?

Posted: Tue Aug 28, 2018 3:09 am
by mknmknmknjk
you use singleton pattern to save info.

Re: Class object that is persistent throughout every level?

Posted: Tue Aug 28, 2018 5:21 pm
by CHADALAK1
I know to use the singleton pattern, but I was still curious what object is persistent when the game starts and where the game ends. Because even when creating a C++ Singleton without a persistent context, it will still be removed after the level has been unloaded. Typically in a game engine there's one place where an object (at least 1) is persistent. Correct me if I'm wrong I would like to know more.

Re: Class object that is persistent throughout every level?

Posted: Tue Aug 28, 2018 5:51 pm
by cry-miron
There is currently not a way to keep Entities alive between multiple levels. Instead you can use CGamePlugin class in the templates to handle persistent systems for your project. The CGamePlugin will be alive during the whole lifetime of the game.

Re: Class object that is persistent throughout every level?

Posted: Tue Aug 28, 2018 7:09 pm
by CHADALAK1
There is currently not a way to keep Entities alive between multiple levels. Instead you can use CGamePlugin class in the templates to handle persistent systems for your project. The CGamePlugin will be alive during the whole lifetime of the game.
Ahh yes. Thank you for that @cry-miron ! I mean I can create a singleton class and have it be created in the CGamePlugin for data regardless. Now I know where I can store the singleton, it will be easy to track data throughout the project. Speaking of which, are there any plans to have a persistent object in the future or is it not the best idea for this engine in particular?