Download

Multiplayer character selection.

Hi guys.
Sorry for my english.
I’m trying to make a small multiplayer game where user can pick a character and then connect to the server with selected character.
So, i have looking some tutorials before start. It was official documentation and some youtube videos.
For example:
https://docs.unrealengine.com/latest/INT/Gameplay/Networking/https://youtube.com/watch?v=uCjXJD9AhqYhttps://forums.unrealengine.com/showthread.php?68965-Blueprint-Youtube-Tutorial-Multiplayer-Lobby

I made my game based on “Shootout game”.
I have 2 map. Hangar and Level
Main algorithm:

  1. User picks character. Selected Character will be saved inside player’s GameInstance.
  2. In hangar user can host or join game. After hosting game server moves to “Level” map.
  3. After joining to the server in OnPostLogin function. This function should ask client which want to connect send his data such as selected character class, selected weapons etc.
    http://joxi.ru/8An5bXNfP3Zl2O
  4. After that client calls on the server function with parameters, at this moment only player class
    http://joxi.ru/brREKDnflX0JA1
  5. And after that server should spawn client character with selected class
    http://joxi.ru/vAWRODesMw7v2W

But i have a problem. If i’m a host server then i can se my character and can control him. But when i’m a client i can join to the server but my character do not want be spawn. But when i moving on the server i found that in that place where client should be spawn contains some collision, but i can’t see client too.
I found points 3-5 do not want be called on the client. What i’m doing wrong?

Ehm, hey there,

could you try to pack the last RunOnServer event, that should spawn the Actor, into your PlayerController, instead of your GameMode?
If i’m not mistaken, you can only call RunOnServer events on actors that the Client has NetOwnership of. And the GameMode only
exists on the Server, so there is not way he knows how to reach this GameMode.

The rest should be ok.

Also, just as a side node: Try to not just “Cast To…” too often. Better do it once at the beginning and save the casted value in a Variable to
reuse it later. This will also help you saving room in your Graph and avoiding so many wires.

Thanks for your reply. I moved my spawn function into PlayerController but still have the same problem. I think i’m doing something wrong :frowning:

Show me how you made this function inside the PlayerController. Because you can remake it and for example remove the PlayerController parameter, since you
are already in the PlayerController that should possess the pawn.

I’m make a screenshoot
http://joxi.ru/1A5QGbJHXeLqAE

http://joxi.ru/EA4n4NbsQe7wmb

And here is my function “ClientPostLogin” which is inside PlayerController.
http://joxi.ru/eAO0Wq6S5LY5ro

I found my mistake. My first mistake was trying to spawn player inside GameMode and second mistake is passing wrong state.
At this moment it was wrong player state in function “Check State”. i’m sorry that i spent your time.
Thank you for your help. I think my problem solved.

(: MAN! Please do never think that you are wasting someones time!
This forum is meant to ask for help and, if it’s not a bug, most of the time people
just did something wrong, which is totally normal and ok!

Happy that you solved it (: If you have questions, please post them!

Finally. I found a final solution how to make a character selection in multiplayer game. This solution are not the best but it will work for first time :slight_smile:
So, first of all i have 2 different maps. “Hangar” and “Level_1”.
Start map is “Hangar”
I have:
GameMode - which contains function “OnPostLogin”.
CharacterController
GameInstance - storing data such as selected character.

I used this tutorial to make a characters list.
When user click on some button i calls function inside GameInstance to save selected character.
cb59638718fd3243a62d0814e41b8a2ee6b2d10b.jpeg

When game was hosted and client wants to connect i made a function for asking client which want to connect send him selected character class. I overrided function “OnPostLogin” inside GameMode.
Input Parameter is a player which wants to join game.
3843f472ccac0f28fa62834270d31aed8401ac90.jpeg

Function “Client Post Login” added into PlayerController and replicates to Owning Client. This function should send selected character class to the server which stored inside Client GameInstance class.
226e0de5b7b169490b7a973d69a1d1550014afd6.jpeg

Function “RespawnPlayerEvent” is a server function. I added into PlayerController to. This function should spawn a character with selected class for player which want to join game.
6dfb3877ac.jpg

And last step is inside PlayerController when BeginPlay event firing i enabling input for character.

My main idea based on example game “Shootout Game”.

Yop, that’s similar on how i did it. Though i saved a string and use a “Switch on String” node to let the Server pick the Class as last instance.
If in one or another way the past string gets lost or modified, my server used the standard skin (default pin of the switch).

But your version works the same :smiley: