x

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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

local and online Multiplayer in same project

Hey guys,

i am working on a coop game and i have set it up as a local multiplayer. The next step for me is creating an online multiplayer by keeping the local multiplayer. I haven´t found fitting documentation for this question. If you guys have a hint how to turn a local mutliplayer into a online multiplayer (by keeping the local), it would be nice if you can give me a link or an explanation. (Yeah i read the unreal documentation to onliine/local multiplayer)

Thanks for the help, Chris

Product Version: UE 4.20
Tags:
more ▼

asked Oct 28 '18 at 07:11 PM in Using UE4

avatar image

Chrismerz
13 1 3

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

1 answer: sort voted first

I have accomplished multiple players on one machine playing against multiple players on another machine in a local area network. Not exactly online but should work similarly.

Going in you should know a few things: Player controllers only exist on their own client machines and not on the others, except the server. The server has all of them.

Player controller ids are always -1 for remote controllers whether viewed from the server or the client. But have numbers 0,1,2,etc for local controllers.

all player States are replicated to all machines. Player controllers are not.

player States dont exist at level start or even player creation but wait until after one or two replication cycles to start existing.

The only base class that comes with smooth network movement is firstpersoncharacter and firstpersoncharacter. Replicating any other pawn class movement results in choppiness which can only be overcome by creating your own smoothing and prediction code.

RPCs require an owning connection. Without it they may execute but not actually work. Client to server RPCs usually work when done via playercontroller which owns connection. Multicast RPCs usually work when done in GameState class. These can work in other classes but when they don't then I move them to these and then they work.

Expanding to networked multiplayer you may need to move some logic from your pawn and controller to the player state, and some of the logic from your game mode to game state.

Remember that game mode only exists of server.

Game instance does not replicate over network so it can be used to preserve local machine's variables between levels.

more ▼

answered Oct 28 '18 at 07:40 PM

avatar image

mightyenigma
3.8k 18 20 20

avatar image mightyenigma Oct 28 '18 at 07:44 PM

Also the only reliable way i have found to identify specific players across network is via the Player state -> player id. It never worked right to use player index Or id from the controller. Maybe works to use replicated pawn reference though

avatar image Chrismerz Oct 28 '18 at 08:25 PM

Thank you for that summary! My Problem is actually how to keep the local multiplayer. For the local multiplayer i don´t need sessions and replicated variables, i can create a second player just by calling "create player".

Will the local multiplayer work with the same setup as the online multiplayer? I am just scared if i change all my blueprints for the online multiplayer, that i can´t get my local multiplayer running.

avatar image mightyenigma Oct 28 '18 at 08:42 PM

What are you trying to do? My setup makes it so 4 split screen players on one machine. Play over network against 4 players on a differe t machine's split screen.

So it is local multiplayer and network multiplayer at the same time. Is that not what you wanted?

avatar image Chrismerz Oct 28 '18 at 08:57 PM

Seems like i didn´t express myself very well. I want to have the option to play the game either local with splitscreen or over a network with a friend.

avatar image mightyenigma Oct 29 '18 at 08:25 PM

Mine Also can do local splitscreen without networking, using the same code.

If you are in local non network multiplayer then calls to the server just hit the local machine and the game acts normal because the local machine is its own server. If youre worried though you can tell it not to create a session. It is fine either way.

RPCs and replication when running local only multiplayer like split screen, work just fine even thiugh there is no server or clients tryinf to talk to each other. The engine just runs them all like they are normal non networking functions in that case. At least in blueprints it does.

My project also works with the same code to do local multiplayer only. Code that works with both networked multiplayer and local multiplayer will also work with local only multiplayer or even just single player.

However, code that works with local only multiplayer will not necessarily work with networked multiplayer.

Just be aware that networked multiplayer is 5x as complex as local multiplayer so you have a lot of work ahead of you.

avatar image Chrismerz Oct 29 '18 at 08:56 PM

Thank you for that anwser, that is what i was looking for. I know that there will be a ton of work, but a lot of stuff to learn as well, so i am looking foward to it.

(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