Download

Multiple PlayerController classes

I have a game where there are two types of players, which have different conceptual roles in the game.
Type A is playing in VR, and can manipulate weapons, items, etc.
Type B is playing on the desktop using a mouse and keyboard, has a HUD, and has different inputs.

I decide which Pawn gets spawned for each player based on the URL options string.
I am trying to determine if there’s a way that these two players don’t have to share the same PlayerController class. Right now I have a boolean flag which tells me if it’s the B type player or not, but it seems dirty to implement the controls for both player types in the same class, and check this flag for each method.

Ideally I would spawn a separate PlayerController for each player type, but the method which handles this in GameModeBase does not have access to the URL options string:


APlayerController* SpawnPlayerController(ENetRole InRemoteRole, FVector const& SpawnLocation, FRotator const& SpawnRotation);

One thing I could try to do is replace this method and override the Login and HandleSeamlessTravel methods to call my new method instead of this one, but is there an easier way?