Creating games with Crayta: Server-Client code, Lobbies and Multiplayer concepts

Jordi
6 min readJul 28, 2020

Crayta is a Stadia only game or platform that allows players to build games. It is very similar in concept to Roblox or Minecraft; as Crayta creators (that’s the official name) build worlds with game physics engines based on voxels, meshes and code. Furthermore, Crayta comes with a big bet from their side: they believe game creation should be a collaborative multiplayer experience. And wow, that’s a big assumption that this company does. Time will tell whether that assumption is right.

Crayta platform

Crayta has been available for less than a month, and as any brand new development plataform, it lacks of good documentation. Don’t get me wrong, vast documentation can be found on developer.crayta.com, with extensive tutorials; also on Crayta youtube channel, where you can find high quality streamings on different Crayta topics and use cases; and on Discord, where you can find Crayta developers at any time answering endless hordes of complex and specific questions (I am a witness of this, every single day, weekends included).

Crayta Discord. An amazing place to meet other creators, and the Crayta developers themselves. Thanks!

But, as you can see, documentation is scattered among different channels, and Crayta creators might find difficult to find specific answers to their specific questions. I’m missing more permanent question-answers on Stackoverflow at this point, for example. In fact, the great idea of answering real time questions on Discord is opposite to the great idea that these questions could be permanently saved in an accessible and popular site as Stackoverflow.

This happened to me when I had to check how to approach my game from a multiplayer point of view. I was missing the main concepts that other creators may already know because of their experience playing other multiplayer games, and I couldn’t find any single page that could answer me the basic questions of what should I take into account. This post is an attempt to solve this.

I’ve been working on a “Escape from the Museum” game within Crayta in the last month, and I’m really excited because of how easy and enjoyable the whole experience is being. The game is in the last tests, and I hope you can enjoy it soon. But, once I developed all puzzles from a single player point of view, I started to wonder how to approach them from a multiplayer point of view. And here are the concepts I learnt during all these questions. Thanks Crayta Developers (and Adam) for patiently answer all my questions.

Escape From the Museum cover

Types of game depending on how users group

I wish I had thought first of how the whole multiplayer experience would affect to the game. I started developing it as single player, but I should have thought it from a broader perspective. Specifically, before starting, creators should ask themselves what type of multiplayer experience they want to provide

This means that creators should define if the game is going to be:

  • (1) all vs all experience (free for all, deathmatch)
  • (2) team vs team experience (capture the flag)
  • (3) a one team collaborative experience (a group adventure)
  • (4) a team experience, but competing with other teams in the total score (group adventure with score)
  • (5) individual experience, competing with other teams in the total score (individual adventure with score).

There are no more type of games that you can develop in Crayta. Actually, there is no single player experience, as these games do not have a meaning in the Craytaverse.

Server / Client / Local

The previous positioning of your game will allow you to answer if things should happen in the server (for all clients), or in client / local (for each player). For example: if a door opens, does it open for everybody (server), or just for a player (client). And it is important to think all of these aspects in every action of the game, because your code will depend on this decision, and if you change your mind, you will need to change your code. Lots of it.

Crayta has a wonderful way of solving the Client / Server wiring difficulties, but it does with “black magic”, this means, hiding to creators all the complexity, which is great for newbies, and at the same time, it doesn’t allow them to understand what’s going on under the hood. Servers and Clients share the same codebase, which are scripts, although the execution flow is different. As a newbie, you don’t understand this after several days trying to know why a specific code doesn’t work, and finally you learn that it’s because it doesn’t make sense in the server, only in the client or local. Once you master this, the ability to have one script and all methods available for server and local execution flow is a huge game changer.

All the info you need to know about this can be found here: https://tutorials.crayta.com/client-server-relationship-and-how-they-communicate/

Game servers and instances

You cannot do truly single player games. This means that one game instance (the execution of one game) will be filled up to a number of players, so a universe of your game will always be shared with different users, up to a number of players you define per game, with a minimum value of 4.

According to Adam, from Cayta devs: “If the game isn’t active, you’ll start into a new instance of it. If there’s an active instance in your region (US/EU etc.) then you will join that instance, provided it has space — if it’s full, you’ll start a new one.”.

You cannot control, then, when players enter your game. So you must define an experience of what happens when users enter in half of the game: should they wait until current players end, or they should play in another section of the map, or they can join directly to the existing game?

Lobbies

This leads us to the concept of “Lobby”. Lobby is the common name used to refer to the place where people gather until a new round exists in the game instance you enter.

You must define and think what the experience should be in that case. In the most common case in which users gather in this lobby, Crayta already comes with a LobbyScript, a LobbyWidget and a GameScript that synchronize to show all this: the door to join the game is closed until a time passes or a specific number of users is reached. It’s really easy to implement it.

Other developers have come up with very creative different implementations. For example:

  • Players can see other users play, while they wait “outside”. This is a fantastic way to learn and create expectation while you wait.
  • Players can go through a tutorial while they wait in a lobby.
  • Rounds execute in different parts / rooms, and players progress in rooms, so new players start in an empty room, and the next room is open when previous players have finished.

Conclussions

Crayta is an enjoyable and unique experience to create new games, and it allows you to create multiplayer games. Although Crayta developers have put great focus on teaching and creating docs on this new platform, the result is that this documentation is quite scattered. My intention with this article was to provide new creators a way to understand the basic concepts of how to design a new multiplayer game.

My Stadia name is heedrox, I hope to see you in Crayta!

--

--

Jordi

Learning and growing in teams that develop software and create impact. I work in @lifullconnect