Announcement

Collapse
No announcement yet.

Multiplayer character selection.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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...ay/Networking/
    https://www.youtube.com/watch?v=uCjXJD9AhqY
    https://forums.unrealengine.com/show...tiplayer-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?

    #2
    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.
    Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

    My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
    (Including 100+ Pages Multiplayer Network Compendium to get you started.)

    Comment


      #3
      Originally posted by eXi View Post
      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

      Comment


        #4
        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.
        Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

        My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
        (Including 100+ Pages Multiplayer Network Compendium to get you started.)

        Comment


          #5
          Originally posted by eXi View Post
          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.
          Last edited by eXi; 09-03-2015, 09:01 AM. Reason: Doublepost

          Comment


            #6
            (: 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!
            Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

            My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
            (Including 100+ Pages Multiplayer Network Compendium to get you started.)

            Comment


              #7
              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.
              Click image for larger version

Name:	48f5c98242.jpg
Views:	1
Size:	188.0 KB
ID:	1086944

              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.
              Click image for larger version

Name:	cc1a77d13e.jpg
Views:	1
Size:	250.4 KB
ID:	1086945

              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.
              Click image for larger version

Name:	9d23942b5d.jpg
Views:	1
Size:	425.5 KB
ID:	1086946

              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.
              Click image for larger version

Name:	6dfb3877ac.jpg
Views:	1
Size:	466.0 KB
ID:	1086947

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

              My main idea based on example game "Shootout Game".

              Comment


                #8
                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
                Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

                My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
                (Including 100+ Pages Multiplayer Network Compendium to get you started.)

                Comment

                Working...
                X