I have been developing a third person shooter and currently just have a single player mode. I want to add split screen functionality, but every time i create a new player from the UGameplayStatics::CreatePlayer(index, bShouldSpawnPawn): it creates the second player and his pawn fine, but then the first controller automatically un possesses its pawn and becomes a spectator… Wondering if anyone else has had a similar problem with split screen functionality ?? Any help is appreciated!
No directly an answer, but the “bShouldSpawnPawn” is actually not spawning a Pawn but a PlayerController.
Found that out last time I digged into the Source Code of the BlueprintNode.
The call ends in creating a PlayerController for that Player.
Is that maybe a hint to you what could go wrong?
I Realized that myself when experimenting with different outcomes when checking the box. If you dont check ‘spawnPawn’ then half the screen is left blank, as if it didnt create the player controller
Another strange issue is when i toggle splitscreen mode, and then remove the player, as soon as i begin the match, i control the desingated pawn for about 3 seconds and then my controller un posesses the pawn and becomes a spectator… ? Is there a different way to add splitscreen to your game that i am missing ?
Maybe setting things up in BP first / watching this primer will help with the workflow:
Add Gamepad Special Right -> call Spawn-Character custom event (Pass a ref to PC).
Add Spawn-Character custom event -> Create Player -> Spawn Actor -> Possess (using PC ref)
(Its easy to follow above except ‘Skip assigning Gamepad to Player 1’ tickbox didn’t work for me).
Overall it seems like C++ is a must for Split-Screen, but maybe someone knows:
#1: In BP, how do you unCreate Player… There’s no node for that.
(Cancel Split-Screen and revert viewport to fullscreen single-player view…)
#2: In BP, how do you let 1-4 players choose the quadrant they want.
(Associate ‘Create Player’ split-screen windows with specific controllers etc…)
To answer your questions above:
#1 - theres a node called “RemovePlayer” which takes the player controller reference in which to remove, and a bool if you want to destroy the pawn or not.
#2 - The engine automatically splits the viewport into 4 even squares. If there are 3 players, you can change whether to favour the top or bottom screen in the project settings menu.
Ive tried narrowing down my problem, and it seems like the default pawn class for my player controller gets reset or erased when I add another player. Does anyone know how to set or reset the default pawn class for a Player Controller ? Other than just setting the default pawn class in the game mode.