How to switch between player controllers?

Hi there, I’m using a 3rd party plugin with its featured player controller class and it works well, however I wanna switch it back to the normal 3rd person template player controller after certain event.

Here’s my blueprint to pass the control from current player controller to another.

I’m trying to

  1. spawn a character to certain position

  2. unpossess current controller

  3. spawn a new controller (default one in 3rd person template)

  4. let the new character & controller possess

But actually the character is coming out to world while the active controller is still the obsolete one. Anyone may help on this?

As far as I know there is no way to change the controller during a level in BP.

You can set the gamemode when you change the level as additional option in the “Open Level” node which includes the controller so you could just create a few of those and switch on level transitions. Besides that there isn’t really a way, though you could just put your functionality inside of the original controller as well.

If you have to swap at any time this might be the best solution.

I hope this helps.

Cheers

It’s not a simple dropdown option.

The “Open Level” node has the fields “Level Name” and “Options” (those are the interesting ones for us).

“Options” basically works like a URL parser for engine specific variables. There is documentation about this somewhere… but this answer has been quite a while ago and I don’t have a bookmark around.

But basically to select your gamemode you need to use something like this for your options:

?game=/Game/[YourPath]/YourGameMode.YourGameMode_C

“/Game/” is technically pointing into your “Content” folder. The rest is your filepath to your gamemode. Don’t forget the “_c” and yes. You repeat the name twice with a “.” in between.

For ease of use you can also do something like this to your “DefaultGame.ini”:

[/Script/Engine.GameMode]
+GameModeClassAliases=(ShortName="YourShortName",GameClassName="/Game/[YourPath]/YourGameMOde.YourGameMode_C")

Which would mean instead of using the filepath you can use the short version. Which allows you to write less and only change one line if you happen to move your game mode around in your file hierarchy.

Cheers

2 Likes

Is this outdated? I don’t see any option in Open Level node to change game mode.

In UE5:
image

Am I supposed to write the word Game? Example -
“?MyProjectsName=/Game/FilePath/GameMode.GameMode_C”

option for “?listen” if it is a online game,