Skip to main content

Godot

Bullet Mayhem is a 2D 1v1 shooter built with Godot that demonstrates dedicated server hosting on GameFlow using a direct connection (IP and port).

Bullet Mayhem Lobby

Prerequisites

  • Access to the Bullet Mayhem repository (Early Adopter access required, contact GameFlow support)
  • A GameFlow account
  • Godot 4.6

Step 1: Clone the Repository

git clone https://github.com/GameFlowGG/bullet-mayhem
cd bullet-mayhem

Step 2: Open the Project

  1. Launch Godot 4.6
  2. Click Import on the project manager
  3. Navigate to the cloned bullet-mayhem directory
  4. Select the .godot project file
  5. Click Import & Edit

Step 3: Install the Agones SDK

GameFlow uses Agones for game server lifecycle management. Install the Godot SDK:

  1. Clone the Godot Agones SDK
  2. Copy the addons/agones_sdk folder into your project's addons/ directory
  3. In Godot, go to Project → Project Settings → Plugins
  4. Enable the Agones SDK plugin

Step 4: Agones Integration

The Bullet Mayhem project demonstrates the key Agones SDK integration patterns.

Initialization

func _ready():
AgonesSDK.start()

multiplayer.peer_connected.connect(peer_connected)
multiplayer.peer_disconnected.connect(peer_disconnected)

if "--server" in OS.get_cmdline_args():
hostGame()

Health Checks

var elapsed_time = 0.0

func _process(delta):
if peer:
elapsed_time += delta
if elapsed_time >= 60.0:
AgonesSDK.health()
elapsed_time = 0.0

Player Tracking

GameFlow tracks player counts through the Agones players list (Counters & Lists). The Godot plugin doesn't expose this, so report players through the local Agones REST API:

var agones_port = OS.get_environment("AGONES_SDK_HTTP_PORT")
if agones_port == "":
agones_port = "9358"
var base_url = "http://localhost:" + agones_port

func update_player_list(player_id: String, op: String):
var http = HTTPRequest.new()
add_child(http)
var body = JSON.stringify({"value": player_id})
http.request(base_url + "/v1beta1/lists/players:" + op,
["Content-Type: application/json"], HTTPClient.METHOD_POST, body)

func peer_connected(id):
if multiplayer.is_server():
update_player_list(str(id), "addValue")

func peer_disconnected(id):
if multiplayer.is_server():
update_player_list(str(id), "removeValue")

See Player Tracking for the full list of supported engines and SDKs.

Server Start

func hostGame():
peer = ENetMultiplayerPeer.new()

var error = peer.create_server(server_port, 2)
if error != OK:
return

peer.get_host().compress(ENetConnection.COMPRESS_ZLIB)
multiplayer.set_multiplayer_peer(peer)

AgonesSDK.ready()

The player list capacity comes from the Max Players per Server value you set on the game in GameFlow, so the server doesn't set it.

Step 5: Export and Zip

  1. In Godot, go to Project → Export
  2. Click Add... and select Linux/X11
  3. Click Export PCK/Zip → save as game.pck
  4. Create a .zip file containing the exported PCK

Step 6: Create a Game on GameFlow

  1. Log in to your GameFlow account
  2. Navigate to the Games section → Create New Game
  3. Set Name to Bullet Mayhem

Step 7: Configure Server Settings

  1. Set Memory to 1GB
  2. Set vCPU to 1 core
  3. Set the Port to 8910
  4. Enable the us-east region

Step 8: Deploy and Test

  1. Upload the .zip file in the builds section
  2. Click Create Test Server, wait for the server to reach "Ready"
  3. Run the game locally in Godot, enter the server IP and port, and click Join

Bullet Mayhem In-Game