This Godot game server integrates with the GameServerAPI to manage its lifecycle, authenticate players, and update data like player counts.
A Game Client implementation in Godot can be found here.
- Server Registration: Automatically registers the game server with the GameServerAPI on startup, using credentials provided via runtime arguments.
- Player Authentication: Validates players via API request using PlayerJoinTokens when they attempt to join the game server, ensuring they are authenticated and authorized to play.
- Data Updates: Regularly updates player counts and server status through the API.
- Server Authentication and Initialization: Provides options to set the server name, port, and authentication credentials via runtime arguments or editable script variables.
- Provides a simple 3D environment where players are able to move around, labeled with their username.
Installation Guide
-
Download the Source Code
- Visit the GitHub repository at
https://github.com/robert-caulfield/GameServerAPI-ServerGodot. - Click on
Codeand selectDownload ZIP, or clone the repository using:git clone https://github.com/robert-caulfield/GameServerAPI-ServerGodot
- Visit the GitHub repository at
-
Open the Project in Godot
- Open the Godot Engine.
- Select
Import Projectfrom the Godot Project Manager. - Navigate to the downloaded directory and select the
project.godotfile. - Click
Import & Editto open the project.
-
Configure Credentials and Game Server Information:
-
Navigating to
Project > Project Settings > Editor > Run, and set the credentials, port, and name of the game server based on the needs of your project.Example Runtime Arguments:
--username=Admin --password=Admin123$ --port=6545 --server_name="Game Server"Login information can also be provided in
SignIn.gd:var username := "" var password := ""
-
Additional game server information can be modified in
GameServer.gd:# Server Info const DEFAULT_PORT = 6545 # What port is set to if none is defined in arguments const DEFAULT_SERVER_IP = "127.0.0.1" # What ip is set to if public ip is not fetched const MAX_CONNECTIONS = 8 # Max players const DEFAULT_SERVER_NAME = "Server" # Name of the server if none is defined in arguments const PLAYER_AUTH_TIMEOUT = 10.0 # Time in seconds that a player has to authenticate const HEARTBEAT_INTERVAL = 30 # Time in seconds that a heartbeat is sent
-
-
Configure the API Endpoint
- Navigate to the
api_helper.gdscript in the Godot Editor. - Locate the
API_URLvariable and set it to the correct endpoint URL for your GameServerAPI:# Base url to api const API_URL = "https://localhost:7242/api/"
- Save the script.
- Navigate to the
-
Run the Project
- Ensure the API is running, and run the project.
- Godot v4.21