What is recommended class type for manager class?
Hi, i am planning for structure of my code work and i wonder what class type would be nicely fit for manager class.
since i am quite new to unreal and programming, i want to hear all the opinions as i can.
so far, my plan is make a game instance class that store all the manager classes ( like handling object per type or team, handling save data, store or process some data for something and etc ) and that instance class will create all the managers when instance created and destroy when it dies. since the game instance will exist only one instance, it would work well i guess.
before this project i am working on, i learn singleton and use it for manager classes but since either unreal doesn't recommend singleton and recommending use game instance which only can create one instance. i think it is the best way as i can think for now.
long story short, i really don't have any experience for working with unreal. so that i want to hear what class type is best for creating manager class and why.
it would be great if i can hear code structure tips for manager classes ( instead storing all manager classes in game instance class )
Using your own GameInstance class derived from UGameInstance is the way to go to create that "singleton" like class for your project. This is how I did it on my first UE4 project, and when I went to work for another studio, what do you know, this is also what they did! The GameInstance class as 2 functions you can override that will be useful in your case of creating and managing your game "managers":
As for the managers themselves, it depends on what you need them to do,, but I would say that 90% of the time, you should just make it derive from UObject.
Hope this helps and good luck with your project.
answered Dec 12 '18 at 03:27 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here