Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Need help with Multiplayer LAN

Hi all,

I am just starting to make a LAN multiplayer game using blueprints. One thing I read a lot on the internet is that on local multiplayer (I presume this means LAN) games, the Get Player Controller player index input actually is important. Is this true? For example, if I want to get the player character associated with a Game Instance, what I would think to do is inside my Game Instance BP use Get Player Character with player index left at 0. But is this the correct thing to do on LAN multiplayer? Do I need to use the player index input? If I do, then how do I do things like this? How do I find out what index my player associated with that game instance is at?

Thanks for the help!

Product Version: UE 4.19
more ▼

asked Apr 24 '18 at 04:47 PM in Blueprint Scripting

avatar image

52 6 12 22

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

By trial and error and help from other users I found the following things:

Player Controllers are not shared between server and clients at any level or via any objects, except maybe to let the server know there's a player connected to it remotely, but remote player controllers always have an index of -1 no matter what you try to do to change it. Indexes >=0 mean a player on that same machine, not a remote one.

Player States are replicated and exist on server side and client side but if you want to change them from client you probably have to send a client to server RPC.

Player States have an ID that is unique across all machines, but player controllers' index only exists for the machine they belong to and are used to map to physical devices like game pads, keyboards etc, and to match them up with viewports and to know which one you're grabbing if you don't do it by relation to pawn, owner, etc. (which is usually better).

You can't get a unique ID or index of a remote player controller, not even from the server's side.

You CAN get a unique ID of a Player State from the server's side and the clients' sides.

Player Controllers can possess Pawns, but Player States cannot. However, Player Controllers know which Player State belongs to them.

"Owner" references climb a chain of objects that are related to each other until one is found. Usually with regard to pawns, this finds a player controller.

more ▼

answered Apr 30 '18 at 03:07 PM

avatar image

3.8k 18 23 20

avatar image MarsMiner Apr 30 '18 at 07:21 PM

Thanks! This is really helpful.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I think you may confusing split screen which is also ccalled local multiplayer with network play over LAN network. But in issue you describing it does not matter, the point is in any form of multiplayer you dealing with more then one player and each player have specific set of object.

Each player joinging the game have UPlayer object made which is not acceable in blueprints, then from that PlayerController is made which is representation of player control interface, you should be already aware that PlayerController is one possessing the pawns in the world and controls is by feeding it with control data from player, each player have that controller and each player posseses pawn that he controls. There only one Game Instance and only one Game Mode, those aren't associated with any player ,the manage all the players in the world and in networked game they exist only in server.

Now about id input, whatever it is importent depends on which player character or controller (since oyu probably notice there similar ndoe for that) you want to access, you use those only if you really want to address specific player. In most cases you should access those things via relation, for example you got overlap event with a pawn, event return you a actor that cause the event you check if it's pawn, if it's pawn you can check if it is possessed by any player controller and you can get that controller from Get Controller node.Lot of events return actor, pawn and controllers that are related to event, so if you can use those insted,

But if you really want to use those nodes you need to assing IDs yourself in Player Controller , i not sure if UE4 does that automaticly if it does another player will have ID 1 and so on.

more ▼

answered Apr 24 '18 at 08:56 PM

avatar image

37.3k 936 172 1116

avatar image MarsMiner Apr 25 '18 at 06:02 AM

Thanks so much for your help! This is really useful. I am currently trying to set up saving in multiplayer- when the server quits I want it to save the location of all the players and what they are holding ect. How do I do this? I thought maybe the server could do a for each loop of get all actors of class MyCharacter but I don't think it is working. Also, I probably need some kind of unique ID for each player. Can you help? Thanks!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question