Skip to main content

Godot

This sample project demonstrates how to build a multiplayer game with Godot that integrates with GameFlow. Bullet Mayhem is a 2D 1v1 shooter built with Godot, showcasing the basics of multiplayer game development and how to host a game server with GameFlow using a direct connection (IP and port).

Bullet Mayhem Lobby

What You'll Learn

  • Build dedicated game servers with Godot
  • Integrate with Agones SDK for game server management
  • Deploy and configure servers on GameFlow

About Agones

GameFlow uses Agones under the hood for game server hosting. Agones is an open-source game server management system that helps with:

  • Health Checking: Monitors that your server is running properly
  • Player Tracking: Keeps track of connected players
  • Server Lifecycle: Manages when servers start and stop

By integrating the Agones SDK into your Godot game, GameFlow can properly manage your servers and track player connections.

Prerequisites

Before starting, ensure you have:

  • Access to the Bullet Mayhem repository (Early Adopter access required - contact GameFlow support)
  • A GameFlow account
  • Basic understanding of Godot and GDScript

Step 1: Clone the Repository

The Bullet Mayhem repository is currently only available to Early Adopters. If you don't have access yet, please reach out to a GameFlow support member.

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

Step 2: Download Godot

Download Godot 4.6 Stable from the official website:

👉 Download

Step 3: 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 4: Install the Agones SDK for Godot

To enable GameFlow's server management capabilities, you need to install the Agones SDK for Godot.

Installation Steps:

  1. Visit the Godot Agones SDK repository

  2. Download or clone the repository:

    git clone https://github.com/AndreMicheletti/godot-agones-sdk
  3. Copy the addons/agones_sdk folder into your project's addons/ directory

  4. In Godot, go to Project → Project Settings → Plugins

  5. Enable the Agones SDK plugin

Step 5: Understanding Agones Integration

The Bullet Mayhem project demonstrates key Agones SDK integration patterns.

Initializing the Agones SDK

When your server starts, initialize the Agones SDK in the _ready() function:

func _ready():
AgonesSDK.start()

# Setup multiplayer callbacks
multiplayer.peer_connected.connect(peer_connected)
multiplayer.peer_disconnected.connect(peer_disconnected)

# Start server if launched with --server flag
if "--server" in OS.get_cmdline_args():
hostGame()

Health Checks

GameFlow needs to know your server is alive and healthy. Send health pings every 60 seconds:

var elapsed_time = 0.0

func _process(delta):
if peer:
elapsed_time += delta

if elapsed_time >= 60.0:
AgonesSDK.health() # Send health ping to Agones
elapsed_time = 0.0

Player Connection Tracking

Track when players connect and disconnect to help Agones manage server capacity:

func peer_connected(id):
if multiplayer.is_server():
AgonesSDK.player_connect(str(id)) # Notify Agones

func peer_disconnected(id):
if multiplayer.is_server():
AgonesSDK.player_disconnect(str(id)) # Notify Agones

Server Initialization

When hosting a game, set the player capacity and mark the server as ready:

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.set_player_capacity(2) # Set max players
AgonesSDK.ready() # Tell Agones the server is ready

Step 6: Export the Game Server and Zip it

To deploy your server to GameFlow, you need to export it as a Linux PCK file:

  1. In Godot, go to Project → Export
  2. Click Add... and select Linux/X11
  3. Click Export PCK/Zip at the bottom
  4. Use the name game.pck
  5. Click Save
  6. Create a .zip file containing your exported PCK file

Step 7: Create a Game on GameFlow

  1. Log in to your GameFlow account
  2. Navigate to the Games section
  3. Click Create New Game
  4. Fill in the game details:
    • Name: Bullet Mayhem
    • Description: A 2D 1v1 multiplayer shooter

Step 8: Configure Server Settings

Before uploading your build, configure the server requirements:

  1. Set Memory to 1GB
  2. Set vCPU to 1 core
  3. Set the Port to 8910 (or match your server_port variable if you changed it)
  4. Enable the us-east region (only region supported for now)

Step 9: Deploy and Test

  1. Upload Your Build:

    • Drag and drop the gamezip file into the builds section
    • Wait for the upload to complete
  2. Initialize a Test Server:

    • Click Create Test Server
    • Wait for the server to spin up (this may take 30-60 seconds)
    • Once ready, you'll see the server IP and port
  3. Connect and Play:

    • Open Godot and run the game locally (not as a server)
    • Enter the server IP and port from the GameFlow dashboard
    • Click Join
    • Open another instance or have a friend join to start the match!

Bullet Mayhem In-Game

Direct Connection Architecture

Bullet Mayhem uses a direct connection model where:

  1. The server runs on GameFlow infrastructure
  2. Players connect directly using the server's IP address and port
  3. No matchmaking service is required - perfect for testing simple multiplayer games

Troubleshooting

Server Won't Start

  • Check that the port (8910) is correctly configured in both code and dashboard
  • Review server logs in the GameFlow dashboard

Can't Connect to Server

  • Ensure the server status shows as "Ready" in the dashboard
  • Verify you're using the correct IP and port
  • Confirm the server has available player slots