Exploring New Multiplayer Features in Godot 4
In this chapter, we will set up a CharacterBody3D scene for the player with the default movement script attached and a scene where the players will spawn a character into a multiplayer game. We will create a menu with Host and Join buttons so that we can run two debug scenes.
The first button is to simulate a game as the host server and the other one joins a game as a client. We will use the new MultiplayerSpawner node to spawn an instance of the player to the hosted scene. We will synchronize players with the MultiplayerSynchronizer node. We will also make the player unique when they spawn into a multiplayer game. We export the Spawner project and use Windows Command Prompt (CMD) to create a headless server. We will write a GDScript script to use the Universal Plug and Play (UPnP) class to port-forward on a peer-to-peer (P2P) network.
In this chapter, we will cover the following recipes:
- Using the new MultiplayerSpawner node...