Set GameMode in Plugin C++
I am currently developing an unreal plugin, which also contains a gamemode / playercontroller class. So I got this button in the editor working which sets up my scene for the plugin to work, the only thing that is missing is the custom gamemode, which then has to be set in the world settings manually.
I just wanted to ask if there is a possibility to set the current level gamemode in the plugins c++ code? As I said, the gamemode comes packed in the plugins content folder, it just has to be assigned...
Thanks in advance!
asked Mar 21 '17 at 12:08 AM in C++ Programming
I don't know if you still need an answer but I think I have one for you because I needed the same thing and I just found out how it works.
My setup is just like yours that I also have a custom button in the editor and as soon as I press it I do the following in the clicked method:
The PluginManager here is a Singleton class that stores all the important information about my plugin that I need all the time - e.g. my gamemodeclass...
The getInstance() looks like this:
The getGameModeClass() looks like this:
The setter looks like this:
The member itself looks like this:
I did the assignment inside the constructor of my gamemode, because it is executed when starting the editor and I then already have a reference to the class without having to find it with the ClassFinder: PluginManager::getInstance()->setGameModeClass(this->StaticClass());
This works if your GameMode is a C++ class. I guess if your GameMode is a BluePrint, you would have to get the Class like this:
If you still have questions feel free to ask.
answered May 27 '17 at 08:53 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here