Announcement

Collapse
No announcement yet.

UMG Widgets and Multiplayer

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

    UMG Widgets and Multiplayer

    Hi guys, I need your help.

    I'm trying to make a simple LAN multiplayer demo with the FPS Template. I have 2 Blueprint character classes. One is named Hunter, the other Creature. Each have their own UMG (Blueprint Widget).

    Here is my Hunter Widget : http://prntscr.com/82ax45
    Here is my Creature Widget : http://prntscr.com/82axss
    Here is the event beginplay of Hunter : http://prntscr.com/82ayfs
    Here is the event beginplay of Creature : http://prntscr.com/82ayv7

    The problem is that the texts are overlapping each others (on server and client) : http://prntscr.com/82az73

    I hope you could help me.

    Thanks.

    #2
    Eeehm, that might happen because in Multiplayer, you have a version of these Characters on each game.
    The Hunter Blueprint has an Actor that the Hunter Player controls in the Hunters Game, but also one that is controlled
    over the LAN in the Creatures Game. You are creating the Widget on BeginPlay. BeginPlay will be called on EACH instance.
    That means, that not only the Hunter in the HunterGame calls that, but also the duplicated HunterActor in the Creatures game.
    Resulting in adding the Interface to him too. Same goes other way round.

    You will want to do it like this:



    I think this should make sure that only the local controlled Pawn calls it and the LAN Pawn will not.
    Reach out to me if this is not working or if you did not understand something of what i've written. (:

    (Note: I did not use any Widget Class there, nor added it to the viewport. You will want to do this the same way you already did at this part)
    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
      Well, I think I've understand your explanation, thanks!

      But I don't know how to solve my problem ^^. I tried "is Locally Controlled" node, but it doesn't work...
      Now, only the server has text : http://prntscr.com/82fnvl

      But, there is something that I don't understand. I created a "Print String" node to the result of "is Locally Controlled" on the client, and the result is "false". Why ?

      I really appreciate your help.

      Comment


        #4
        Weird, this is perfectly working on my end. I will show you how i have done it:

        Create 2 different CharacterBPs, Player1 and Player2. Difference is the Material of the Mesh
        and the Widget they create:

        Player1:



        Player2:



        Only the Widget Class is different. The Widgets are the same like yours, just "Hunter" and "Creature"
        text on the top mid of the screen.

        Now, since we have 2 different classes, i set the DefaultPawnClass of the GameMode to NULL and spawn the
        Characters myself. This has to be done on the Server only!

        The GameMode Class only exists on the Server. It has no Client Version. There is a function called "Event Post Login", which
        gets called once a Player is connected and has a valid PlayerController. I use this to Spawn the Player. This function also
        gives me a reference of the Players PlayerController (still Serverside!). With this i can just call possess on the spawned
        PlayerCharacter. You don't need to call anything on the Client and you also shouldn't!

        So this is the function call on my GameMode:





        The "Counter" is just for me, because i needed something to get 2 different Players. The variable is 0 at the beginning, modulo 2 is still 0.
        Then, after the first Player joined, i add 1 to it, which makes it modulo 2 equal 1. So i get to different "Branch" results. Nothing really
        relevant for your setup. You can decide who is Hunter and who is Creature in your own way.

        But as you can see, i spawn the 2 different Players and possess them with the parameter Controller.
        And that's all (:

        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
          There is something I don't understand.

          I tried your explanation, and it works. But, with my custom "Post Login", it doesn't work. I only have text on my server (Hunter).

          Here is my GameMode class : http://prntscr.com/82l51r

          The difference with your settings is that I have a pawn for DefaultPawnClass instead of NONE : http://prntscr.com/82l6ew

          Comment


            #6
            Hi @eXi, can you help me please ?

            Comment


              #7
              Originally posted by SuperlawX View Post
              Hi @eXi, can you help me please ?
              Hey, sorry i wasn't home the whole time.

              If you spawn you Pawns by hand, you will want to leave the DefaultPawnClass at NONE, because otherwise the Engine will spawn
              it by default. Maybe your error comes from here.

              The PostLogin event in your picture, is that handmade? Because PostLogin is a function that already exists. You only need to search it
              when rightclicking.
              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


                #8
                No problem, thanks for your help.

                Well, I will try with NONE as DefaultSpawnClass.

                No, the "PostLogin" in my picture is not handmade. It's what I have when I'm rightclicking and searching for "Login" : http://prntscr.com/850fme

                Maybe there is a different between them ?

                Comment


                  #9
                  Originally posted by SuperlawX View Post
                  No problem, thanks for your help.

                  Well, I will try with NONE as DefaultSpawnClass.

                  No, the "PostLogin" in my picture is not handmade. It's what I have when I'm rightclicking and searching for "Login" : http://prntscr.com/850fme

                  Maybe there is a different between them ?
                  No that's the correct one then. I was just curious because you said it isn't working with your own version.
                  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


                    #10
                    Thank you so much ! When NONE is the DefaultSpawnClass, it works !!

                    Problem solved

                    Comment


                      #11
                      Wooooooooow thaaaaanks brooo it's work!!!

                      Comment

                      Working...
                      X