I made my game based on “Shootout game”.
I have 2 map. Hangar and Level
Main algorithm:
User picks character. Selected Character will be saved inside player’s GameInstance.
In hangar user can host or join game. After hosting game server moves to “Level” map.
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
After that client calls on the server function with parameters, at this moment only player class http://joxi.ru/brREKDnflX0JA1
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?
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.
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 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
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.
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.
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.
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.
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).