Skip to main content

Initial Setup

Basic initial setup for a godot 3d game in godot 4.3 is as follows.

Set up a basic 3D scene (no multiplayer yet)

Player:

We add a main scene in which everything will be happening.

Create a new scene "player", change root node to CharacterBody3D to start making a very basic player. add a script to it - the script already contains movement controls, but it uses the arrow keys or controllers rather than WASD.

add a collisionShape3D node to it, and to that add MeshInstance3D. select a CapsuleShape for the CollisionShape and a CapsuleMesh for the MeshInstance3D. This gives our player collision, and makes it visible in the game scene.

also add a Camera3D to the player scene, and move it away from the player a bit so you can see it moving around.

Game World:

in the main scene, we will add a node3d "objects" or similar, to fill it with some objects to move around on.

add a StaticBody3D, and to that node add a CollisionShape3D and a MeshInstance3D. select box shape for both. 

Copy this. One of them will be the floor (rename the node) and the other will be a random box we put in the world. Move the floor, and change it's Transform -> Scale to be much bigger, so we can use it as floor. move the box to somewhere on the floor.

Add Multiplayer:

Server

To make a dedicated server, we'll first need a way to tell the game that it's running as server. We can do this by going to project -> export -> add....  and adding an export preset. Here, we're using Linux. Call it Linux Server, and under the Resources tab, select Export as dedicated server. For now, leave everything else as is.

This does 2 things: first, it replaces textures and 3d models by placeholders. since the server doesn't need them, we save space and performance. Second, it'll automatically make the exported executable run with --headless, so we can easily run it on servers without any graphical interface, just using the command line. We can also use this fact in our scripts:

# Note: Feature tags are case-sensitive.
if OS.has_feature("dedicated_server"):
	# Run your server startup code here...
	pass

this info comes from the godot tutorials here: https://docs.godotengine.org/en/stable/tutorials/export/exporting_for_dedicated_servers.html