[Networking] Spawning players on specific player starts
Okay so I am currently working on a small game to play for me and my friends.
Assigning teams is the same logic as in the ShooterGame template.
Now I found out that the way it is programmed in the shootergame template it does not work. This is because the moment a playerstart is chosen the playercontroller doesn't know yet on what team it is.
I also found a really old bug pointing to this. https://issues.unrealengine.com/issue/UE-27464
If somebody would be so nice to point me into the right direction. Preferable someone with networking experience.
I already found the GameMode call logic which is: PreLogin -> ChoosePlayerStart -> Login -> PostLogin
So the moment my playercontroller is assigned a team at the moment is in the PostLogin method which I think is the correct method to put such logic in.
I don't understand why ChoosePlayerStart is called before the Login method because that one creates the PlayerController.
asked Oct 11 '18 at 02:03 PM in C++ Programming
When a PlayerController is initialized it calls FindPlayerStart that calls ChoosePlayerStart and moves the PlayerController and Camera to this spot.
On PostLogin RestartPlayer is called and FindPlayerStart and ChoosePlayerStart is called again to get a spawn location for the Pawn. You may just want to override RestartPlayer and perhaps get the team from there?
answered Oct 11 '18 at 04:43 PM
That's the cleanest way. Another dirtier way is to make the decault pawn class a spectator pawn, and when the player Spawns, do your own GetAllActorsWithTag and use whatever tag you added to the playerstarts you want it to be able to use, and then Spawn at that playerstart's location and possess the pawn.
But I recommend the clean way
answered Oct 11 '18 at 06:20 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here