Custom games

The Rivet matchmaker allows for the creation of lobbies on demand via the lobbies.create endpoint. This guide will discuss in detail all of the configurations available with custom lobbies.


Creation

To create custom lobbies, you must first enable them in your version config:

rivet.yaml

# ...

matchmaker:
  game_modes:
    default:
      actions:
        create:
          enabled: true
          # Public custom lobbies will be listed in the response to `lobbies.list`, private custom
          # lobbies will not
          enable_public: true  # Optional
          enable_private: true # Optional
          max_lobbies_per_identity: 5 # Optional

Now users can create a new custom lobby on-demand like so:

Request

POST
https://matchmaker.api.rivet.gg/v1/lobbies/create
curl
  -X POST \
  -H "Content-Type: application/json" \
  -d "{ \"game_mode\": \"default\", \"region\": \"atl\", \"publicity\": \"private\" }" \
  'https://matchmaker.api.rivet.gg/v1/lobbies/create'

Customization

Additionally, users can input any arbitrary JSON to the lobbies.create endpoint and have it be sent directly to the new custom lobby that will be created. This allows users to customize game properties to their liking.

Request

POST
https://matchmaker.api.rivet.gg/v1/lobbies/create
curl
  -X POST \
  -H "Content-Type: application/json" \
  -d "{ \"game_mode\": \"default\", \"publicity\": \"private\", \"lobby_config\": { \"roundDuration\": 120, \"gravity\": 4.6, \"coinsPerKill\": 100 } }" \
  'https://matchmaker.api.rivet.gg/v1/lobbies/create'

Here's an example of how you might use the user's lobby config:

Game server

// Create Rivet client
import { RivetClient } from '@rivet-gg/api';
const RIVET = new RivetClient({ token: process.env.RIVET_TOKEN });
await RIVET.matchmaker.lobbies.ready({});

// Parse config
let config: any;
try {
  config = JSON.parse(process.env.RIVET_LOBBY_CONFIG);
} catch(e) {
  console.error("Invalid lobby config: ", e);
  process.exit(1);
}

let roundDuration = config.roundDuration ?? 240;
let gravity = config.gravity ?? 9.8;
let coinsPerKill = config.coinsPerKill ?? 50;

// ...

Was this page helpful?

Edit Page

Rivet

Open-source multiplayer infrastructure. Easy, flexible, and affordable.

This website is not sponsored by or affiliated with Unity Technologies or its affiliates. Unity Trademark(s) are trademark(s) or registered trademark(s) of Unity Technologies or its affiliates in the U.S. and elsewhere. | This website is not sponsored by, affiliated with, or endorsed by Epic Games, Inc. or its affiliates. 'Unreal Engine' is a trademark or registered trademark of Epic Games, Inc. in the U.S. and elsewhere. | The HTML5 Logo by the World Wide Web Consortium (W3C), used under a Creative Commons Attribution 3.0 License. Source | The Godot Engine Logo by the Andrea Calabró, used under a Creative Commons Attribution 4.0 International License. Source | Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries. Docker, Inc. and other parties may also have trademark rights in other terms used herein.

© 2024 Rivet Gaming, Inc. All rights reserved.