How to make a game for P2P and Dedicated Networking

First a bit of background: I am currently in the process of developing my game from the ground up to be networked. However, when I initially launch the game, I would like to not have to pay for dedicated servers until I’m sure that I will make enough money from the game to support it. So when I first launch, I would like to launch with P2P networking, and later transition to dedicated servers. I have to date been building my game for the dedicated server model, but I would ideally like to be able to support both models, and possibly even have support for LAN games.

Today I tried running my game in a simple P2P model where Client A spawns the map in “listen” mode and Client B connects to Client A. Since I have mostly developed with the idea that there is a dedicated server, things naturally did not work out so well. I would have to adapt my code alot to take into account that the Authority could also possibly be a player in the game, as opposed to just being a moderator.

I woudl like to get some opinions on which model would work better for a game looking to support both P2P and Dedicated servers:

Option A: Build the game so that it takes into account all the possibilities for both modes. Pro is that all logic is contained in 1 process, Con is that it will create additional complexity each time a new feature is added which requires network replication.

Option B: When the game is started, the host would launch a dedicated server as a separate child process. Pro is that it’s literally identical code for P2P and Dedicated, Con is that the host will need to bear the additional processing cost of a separate process

I am curious what are some thoughts on these two options, and possibly other options that I may not be considering.

Thank you for your time.

Unreal is not set up for peer to peer networking straight out of the box. Both your options are using the client-server model.

You can achieve peer to peer networking if you are prepared to do a lot of testing and research, plus solve a heap of issues around ownership and syncing of actors, but it can be done. You just have to go deep into engine code, understand how UE handles networking, and bend it to your will.

you have BP nodes like IsDedicatedServer, IsServer, IsLocallyControlled to work with. I haven’t had to dive into any engine code to get my games multi-player working properly. That little check box “Run dedicated server” in the play menu is also very useful.

Yes, I suppose both options are technically client server. I am curious though which approach is more ideal, especially in the context of UE4’s networking architecture.