Give specific controller to a specific pawn dynamically?

Hi everyone,

I have to create an asymmetric game in blueprint. I got 2 different pawns spawning in each level. Each pawn has to have a specific controller because we need different views, controls and characters.
So, spawnActor is the answer to spawn a pawn I assume, but as it is a multiplayer game, we’re going threw onPostLogin function belonging to our gameMode. OnPostLogin is giving us a playerController ( the default one I think ).
How can I change this one dynamically ? Why can’t I cast It into my specific player controller ?

Apologize about my english, kind regards.
Yaël.

The first and simple suggestion would be, try to fit everything you need in the same player controller class and just give them different Pawns.

If that does not work, you need to dive into c++ and create a custom GameMode class. Then override “SpawnPlayerController(…)” or even better “Login(…)” . There you can spawn a specific PlayerController. It helps to take a look at the code in GameMode.cpp to see how it is done, you probably can copy most of the code.

First of all thank you for your fast and precise answer !
As both my controller have a complet different behavior, it’s hard to mix them up to make only one. Except maybe with a boolean saying am I behaving this way or the other but that’s really eurk ugly I’d say ( no offense ).

My entire project has been with blueprint so I don’t really know much about how I can instantiate different playercontroller but If there is no other choice I guess I ll have to dive into this beautiful GameMode class :smiley: !
still apologize about the mistakes I can make in english sorry …

I agree, making everything in one controller class can get very ugly, with lots of branches and so. But from all I know this would be the only way to make everything in Blueprints.

It should not be that difficult to make a derrived GameMode class, because you just need to override one method and change a little bit of code. How you determine which player gets which controller is something you need to figure out on your own, but a simple counter should work for the beginning.