← Back to home

Godot SDK

Integrate Asobi into your Godot 4.x project. Install as an editor addon.

View on GitHub

Installation

Copy the addon into your project:

# Clone or download into your project
git clone https://github.com/widgrensit/asobi-godot.git
cp -r asobi-godot/addons/asobi your_project/addons/asobi

Then enable the plugin: Project → Project Settings → Plugins → Asobi.

Setup

Add an AsobiClient node to your scene and configure it:

# asobi_client is an autoload or node in your scene
@onready var asobi: AsobiClient = $AsobiClient

# Configure in the inspector or via code:
# host: "localhost"
# port: 8080
# use_ssl: false

Authentication

# Register
var resp = await asobi.auth.register("player1", "secret123", "Player One")

# Login
var resp = await asobi.auth.login("player1", "secret123")

# Session token is stored automatically
print("Logged in as: ", asobi.player_id)

Real-Time Connection

Connect via WebSocket and listen for events using signals:

# Connect signals
asobi.realtime.connected.connect(_on_connected)
asobi.realtime.match_state.connect(_on_match_state)
asobi.realtime.matchmaker_matched.connect(_on_matched)

# Connect to server
asobi.realtime.connect_to_server()

func _on_connected():
    print("Connected!")

func _on_match_state(payload: Dictionary):
    # Update game state from server
    pass

func _on_matched(payload: Dictionary):
    var match_id = payload["match_id"]
    asobi.realtime.join_match(match_id)

Matchmaking

# Queue via WebSocket (recommended)
asobi.realtime.add_to_matchmaker("arena")

# Or via REST
var ticket = await asobi.matchmaker.add("arena")
var status = await asobi.matchmaker.status(ticket["ticket_id"])

Match Input

Send player input to the server-authoritative game loop:

# Send input (fire-and-forget)
asobi.realtime.send_match_input({"action": "move", "x": 1, "y": 0})

# Send shooting input
asobi.realtime.send_match_input({
    "action": "fire",
    "aim_x": mouse_pos.x,
    "aim_y": mouse_pos.y
})

Leaderboards

# Submit a score
await asobi.leaderboards.submit_score("weekly", 1500)

# Get top scores
var top = await asobi.leaderboards.get_top("weekly", 10)

# Get scores around current player
var around = await asobi.leaderboards.get_around_self("weekly")

Chat

# Listen for messages
asobi.realtime.chat_message.connect(_on_chat)

# Join a channel and send a message
asobi.realtime.join_chat("lobby")
asobi.realtime.send_chat_message("lobby", "Hello!")

func _on_chat(payload: Dictionary):
    print(payload["content"])