I am trying to get my local multiplayer server to work properly in VR. I am running this as a listen server (not sure how to run dedicated servers). When Player 1 enters the lobby, he types ‘open MenuLevel?listen’ to start the listen server. Once Player 1 opens the listen server, the following code is executed within the Level Blueprint.
The code allows Player 1 to possess “VRPawn_1” which is placed in the level by default, but when Player 2 joins the server, it does not possess “VRPawn_2” which is also placed in the level by default. Is there a way to force Player 2 to automatically possess VRPawn_2 when they join the server?
No. This event has a reference to the newly connected player controller. In BeginPlay you can save an array of free pawns (GetAllActorsOfClass), and then in OnPostLogin possess a next free pawn actor from this array. Another way is to place PlayerStart actors at Level instead of pawns and spawn pawn in OnPostLogin at next free location. And, finally, you can select default pawn class in Game Mode properties to allow Game Mode to spawn it automatically for all new players. In this case, use OnPostLogin just to set the desired position for newly connected players.
Thanks, I am using the below code to try and get it to automatically possess Pawn1 and Pawn2 that are placed in the level by default. VRPawn_1 automatically possesses players with ID 0, and VRPawn_2 automatically possesses players with ID 1.
When Player 2 spawns now, it can see its hands, which it couldn’t before, but will not spawn in the correct place. I have 2 Player Start locations in the level, with PlayerStart auto possessing and detecting input from Player0, and PlayerStart2 auto possessing and detecting input from Player1. Does this configuration work properly? PlayerStarts have “Always Spawn, Ignore Collissions” set on Spawn Collision Handling.
Also when checking the log, it looks like it creates Player 2 automatically, without a second player joining, would this be a problem as well?
I created this rough draft here to try and show what I am attempting to accomplish. The only reason I need to possess the two separate actors in the level is because I have to move both actors simultaneously, and have visible replication (replication is implemented within the actors). VRPawn_1 in the level automatically possesses a player with ID 0, and VRPawn_2 automatically possesses a player with ID 1. The problem with this current configuration is that the player possesses both pawns at the same time. Not sure what to do here.
This is in the level blueprint, and it is successfully letting the server possess the VRPawn_1, but the client is not possessing VRPawn_2, even though the console log is saying it is. I know the “Possess” feature is server-side only, so how can I get the client to automatically possess VRPawn_2. I have tried playing around with the OnPostLogin event, but there is no way to get it to possess an actor already placed in the level, only spawn a new one, which will not work for what I am attempting to do with my project. Any help would be greatly appreciated!