Announcement

Collapse
No announcement yet.

EventBeginPlay replicates to all players without without being told to.

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

    EventBeginPlay replicates to all players without without being told to.

    I have multiple players in my game, and when ever i press a key on the keyboard, a weapon is changed to the player who pressed they key, and won't replicate it to other players so only he will see it.
    How ever, when starting the game i want the first weapon to be picked automatically ( just like you start with a pistol in every FPS ), but when i try to do it from EventBeginPlay, it acts like if i was multicasting the command to all clients and they all can see the weapon i'v just picked ( they see a floating gun mesh ) while if i press a key to replace pick a weapon they will see nothing.
    Is that a bug ?

    And if so, how do i tell it to run only in the current player?
    Last edited by Sahkan; 02-14-2015, 07:18 AM.
    Check out my game OldSchool Nightmare : http://www.indiedb.com/games/oldschool-nightmare

    #2
    I guess the way you use the replication tells every player to update every other client on their side. This results in everyone having the gun.

    What you could do is using the PlayerControllers that the server knows. He is the only one who knows every controller. So you could iterate
    through all the PlayerController on Begin Play and call your PickUpFunction through this (Switch has Authority comes in handy to prevent clients
    from doing 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


      #3
      Originally posted by eXi View Post
      I guess the way you use the replication tells every player to update every other client on their side. This results in everyone having the gun.

      What you could do is using the PlayerControllers that the server knows. He is the only one who knows every controller. So you could iterate
      through all the PlayerController on Begin Play and call your PickUpFunction through this (Switch has Authority comes in handy to prevent clients
      from doing the same).
      Thanks for the advice ! I will give it a try.
      Check out my game OldSchool Nightmare : http://www.indiedb.com/games/oldschool-nightmare

      Comment


        #4
        Update : Thank you very much eXi! Works great
        Check out my game OldSchool Nightmare : http://www.indiedb.com/games/oldschool-nightmare

        Comment


          #5
          Update 2 : This solution works great when the game is on dedicated server.
          If there is a player who hosted the game and he is playing as well, he will still affect the other clients, is there any way to deal with that ?
          Check out my game OldSchool Nightmare : http://www.indiedb.com/games/oldschool-nightmare

          Comment


            #6
            What exactly is he affecting?

            Do all player see the weapon of the other players or is only the hosts weapon being replicated?

            I hope someone else can give you advise, because i'm in the middle of learning for an exam
            and i can't concentrate on your problem right now. Sorry ):
            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
              Originally posted by eXi View Post
              What exactly is he affecting?

              Do all player see the weapon of the other players or is only the hosts weapon being replicated?

              I hope someone else can give you advise, because i'm in the middle of learning for an exam
              and i can't concentrate on your problem right now. Sorry ):
              Thanks for trying and good luck with the exam
              every player has a controller that hide the player mesh ( only for him, so it won't obscured his view ) and also activate the "Pick a gun" ( witch is showing a gun in front of him ).
              Every other player needs to not be affected and keep on seeing the player mention above as a character with no weapon.
              Check out my game OldSchool Nightmare : http://www.indiedb.com/games/oldschool-nightmare

              Comment


                #8
                Thanks,

                yes that is your basic idea. My question is, what the listen server (client as host) is now doing wrong for you?
                Normaly it you not make any difference using a dedicated server. Because the server (clienthost and/or dedicated)
                just goes through his list of PlayerControllers (with a clienthost he will have his own PlayerController at 0) and
                runs the function client side with the replicated function.
                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


                  #9
                  This is how the blueprints looks like:
                  MyController:
                  Click image for larger version

Name:	MyController.JPG
Views:	1
Size:	241.4 KB
ID:	1066879

                  MyCharacter:
                  Click image for larger version

Name:	MyCharacter.JPG
Views:	1
Size:	254.3 KB
ID:	1066880

                  And when there is a clienthost on the game, he will see all the other clients as floating gun ( like only he supposed to look to himself ) while all the other clients will see everything as it should be.

                  This is like the clienthost is working on all of the controllers instead of only on it's controller.
                  How can i make him act like a client which is not an host ?

                  *Edit : Ok i'v solved it by changed the "Get possesed pawn" to "Get player character" on index 0.
                  So i guess now it iterates between all controller and works only on the one with character index 0...
                  I would really like to have a better and more neat solution :|
                  Last edited by Sahkan; 02-21-2015, 03:40 PM.
                  Check out my game OldSchool Nightmare : http://www.indiedb.com/games/oldschool-nightmare

                  Comment

                  Working...
                  X