Announcement

Collapse
No announcement yet.

Multiple Player Controllers - Multiplayer

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

    Multiple Player Controllers - Multiplayer

    Hello I'm fairly new to all this and I can't seem to wrap my head around all of it.

    What I want to do seems fairly easy in practice but I'm banging my head against the wall.

    What I want is a First Person player and a player from a top down view using his mouse pointer to select things in multiplayer.

    When I assign the Main player controller here's what happens.

    I spawn in game I Possess my Rts player and everything is fine. He has a mouse pointer and he can select things.
    When I spawn with the FPS character - I disabled Show Mouse cursor and click events but the mouse pointer is still active while hidden and its stuck in the viewport.
    This means my first person player can only turn left and right so far because the hidden mouse cursor stops at the end of the viewport.
    I'm at a loss as to why this is. Is it possible to assign a different player controller to my FPS character and if so How do I do this. If not is there a work around? It's been driving me nuts.

    Edit: I can't believe this... When I was into the First Person Character I have to click twice and the mouse is no longer stuck to the viewport... I'm at a complete and total loss....
    If someone could give me a brief explanation as to how all this works I would appreciate it.
    If changing values to the Player controllers directly in the Characters blueprint does that effect every character on the server or only the character that changed it from it's blueprint?
    When I start a server is this player controller created for every single character on the server? After hours of searching I can't seem to find a definitive answer.
    Last edited by pwminus; 12-05-2016, 01:53 PM.

    #2
    Hey,

    first of all, grab my Compendium and read through it:

    http://cedric.bnslv.de/unreal-engine...dium-released/

    That should answer a lot of network questions.

    To answer your questions:

    No, you can't have different PlayerControllers. A PlayerController is unique to a Player and identifies him.
    But you can possess different Pawns/Characters with him.

    If you want to switch between them, you need to have them both spawned and then call "Possess" on them.
    That will take care of un-possessing the old one etc.

    There are events that are called when you possess the Character (inside of the Character) and when you un-possess it.
    I think something like "OnPossessed" or so. You can use these to create a "Client RPC" (since these Events might only be called
    on the ServerSide of the PlayerCharacter), which then will be executed on the owning client (the one that possess it), so you
    can enable and disable the Mouse in it.

    A few important things here:

    Clients only have their own PlayerController. The PlayerControllers of the other Clients or the Server are not available to them.
    The Server on the other hand has an instance of each PlayerControllers.

    How do you now let the Client switch a Pawn? You need to have a "Server RPC" in the PlayerController and then call Possess in the Server
    Version of that PlayerController. The Client itself should not call "Possess".

    And yes, the if Client A calls a Server RPC in the PlayerController A (his own), the Server will execute the stuff on the Server Version of PlayerController A.
    So you can be sure that it's the correct one.

    If there are words in the text above you don't understand or know, make sure to read the whole Compendium that I linked.


    The part with the mouse can be a PIE problem. To loose the mouse focus, you might need to click once.
    That shouldn't be a problem in the Standalone version.

    Also make sure to use the nodes "Input Mode Game Only" and "Input Mode UI Only" (and the mix of both) to have more control about your UI etc.
    Last edited by eXi; 12-05-2016, 03:24 PM.
    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
      Thanks a lot man. You saved my a$$. Sorry for the delayed comment. When I read your comment I immediately got to work and got a quick multiplayer test working. Come to find out it's entirely possible to have these 2 different players. You have quite the nice read there as well, it'll come in handy.

      Comment

      Working...
      X