The Playtypus Experiment #1

8 minute read

A story about Conveyors - Part 1

The Beginning

Here is the thing … I love conveyor belts in a games as much as I love automation Games in general. So it was only natural for me to build a game that is an automation game. I want to learn in the process as much as possible, reproduce what worked, improve what did not or what , as a player was bothering me. I spent countless hours in games like Factorio, Satisfactory, Dyson Sphere Program. More recently I even play the rought diamond that is Techtonica !

In all these game you have by a way or another conveyor belts serving as the main gameplay element. It’s like hypnosis and satisfaction boost when you are looking at your factory and that it work. ( Either that or it trigger your OCD and you restart the game 5 times to get it just right … ) They come in different Shapes , Forms, have multiples gameplay mechanics around it & it’s always fun to see what Developers come up with when it’s coming to a piece so central to a game.

The main function of a belt is to transport an object from point A to point B. This is the core.

Seems simple, right ? I was thinking that and oh boy I was wrong …

1 - The case of a CodeMonkey

When I started researching on the topic I ended up on a video from CodeMonkey .

( If you still don’t know him, please check him out he is a great code explainer and I definitely learned a LOT from his videos )

Here is how it looks like at the end of the video :

It looks good, works and do the job. And sometimes it’s all we ask. It constantly checks the spaces on the next belts and then move the item from A to B.

Each belt is occupying one tile and is regular allowing for a convenient way to place the belt, a model that is repeated and easily customisable.

2 - The factory Must Grow

Here is the thing either you are in 2D or in 3D , if you can get a regular grid it’s easy once you figure out how to move the items from a belt to an another. The belt is the size of a tile in a squared grid, Exactly like in Factorio ( 2D , A tile ) & Techtonica ( 3D , A cube )

source : FFF-269

Do they have to plan ahead for all combinations possibles ?

Huuuuh kinda, You can optimise and rotate the sprites, but you still have to make the sprites & animate them & all :

source : FFF-269

But this is it for the similarities. They spend a LOT of time optimising that part of the game.

Isn’t that a bit overkill ?

In any factory builder with belts, it’s the main building you are gonna make. so you can end up with thousands of them. If the code behind is slow it can become your main bottleneck & steal some precious fps from your dear players.

Yeah so in the end they do like the Codemonkey prototype approach to move the items ?

Welp … while it’s a tile approach for the visual… In Reality to move the items they split the belts paths into Segments.

source : FFF-176

Then they save the distance value between each item and move the items accordingly. It results in a way more scalable & optimized way of doing that.

Another core difference is that 1 belt can carry 2 lines of items & it’s part of their design so 1 belt = in reality 2 lines so it’s even more important to optimize here. As far as i know they are the only one to do it this way and that’s their identity point ! ( at least , one of them ) and some game mechanics are built around that simple key fact.

Now that’s good and all but these two have a very regular grid to work with. What happen when you don’t have a perfectly squared grid ?

3 - It’s not fair I need to sleep

You get Dyson Sphere Program . The game is happening , instead of a flat surface, on the surface of a sphere. Making a game usable grid on a sphere is … HARD, I read a LOT of papers on the topic and it’s complex. So they did not bother trying to do it. Instead, they use a special grid type that I’ll present to you in another blog post later.

But even then they managed to have belts working :

Alright, what’s the catch ?

First, they don’t follow the previous rule of 1 belt per grid square. When you look closely you can see they get the point between the lines of the grid, not at the middle of the square.

Another DevLog I suppose ?

Yup, and that is not as straightforward as it sound :D but it works.

Lucky for me, having created & worked on the GalacticScale Mod for the game I digged into their code base for, and I’m familiar with how they did it …

As you can see in the video : each belt have small segments you can modify the segments, delete each belt individually.

In the background, like Factorio & Satisfactoy ( foreshadowing ) they have a way to create some sort of dynamic graph that contain all the segments of the factory to move the items along the lines.

But how do they PLACE the conveyors ? The grid look a bit messy, did they made models for each differences in alignment & curvature of the sphere ?

Welp I’m glad you asked !

Give me a break …

I refuse ! Soooooo … First of all , have look :

See the differences ?

Very clear indeed …

As said previously the first difference is that the build point is on the intersection of the lines. Not in the cell. This allows the devs to do something in between these points & to bend the line created in between these points. They create a path for all the line crossing they encounter ( That will be a topic for another dedicated DevLog )

4 - The Green Yellow Line

It turns out that to make conveyor belt that bend ( lol ) to you will you need a little mathematical something ! The secret sauce turns out to be something called a bezier curve between each points.

A what ?

A Bezier is basically the representation of a line, not necessarily straight but could be. Imagine train tracks, you have the start , the end , and the path is not always a straight line.

Alright …

You can represent any kind of shapes you want for your conveyors with Bezier Curves. Once they have this, they can generate the mesh along the “spline” relatively easily.

And one of the advantage of a spline is that it’s easy to evaluate where an item is on it. So what’s happening is that the code do the same as for factorio : the items on the belt follow the spline & some dedicated code take care of handling the transfert of items between the belts segments when different but connected.

Here is a nice tool to play with a Bezier and see how it works : Bezier

Still don’t know what a Spline is … You are Confusing …

While a Bezier Curve is a representation of … a curve, ( yeah I know … ), a Spline is basically a group of these curves with some control points. Just as a note you don’t have to do a Bezier to represent a line, but it’s the most commonly used.

Why ?

Because.

Thank you …

You are Welcome ! , nah I mean it’s really a “simple” way of representing any kind of path, and except if you are certain that your game will ever only have straight lines, you want to represent theses curves.

Here is a representation in DSP :

cf : Look at the yellow interval.

A spline is Basically a list of Bezier Curves ( cf : orange line ) so it’s the curve between A & B - B & C - C & D etc …

Once the spline is calculated the game save that, generate the meshes ( one for each Beziers curves ) along the spline & then forget about it.

Wow, Slow Down …

Future DevLog !

Okey !

5 - Thanks Jace Snutt ! Help a Lot !

And where is all of that bringing us to ? Welp, to the last contender of this list : Satisfactory

What am I supposed to see ?

No grids at all , Just two point gracefully joining to create a belt out of thin air.

When you compare it with DSP another key difference is that when you place a belt it’s a segment that you are placing. You can’t divide ( well , yes but not the same way ) it by removing a piece of it without removing the entire belt.

Gosh I love this game. Play it if you have not !

Sure Seeing the time it’s going to take for your game anyway …

Anyway !

This is the different belts type that i’m aware of that are out there in games you can play today.

We have :

  • The sprite Belt that transport item From itself to it’s neighbor
  • The sprite Belt that do that with a segment
  • The Spline Belt that split up the belt in smaller segments
  • The spline belt that consider a belt as a huge segments

Each type have pros & cons & different gameplay possibilities.

In the next DevLog, we are going to keep digging in that topic, and I’m about to reveal the solution will be used in the game we chose for the prototype of the game.

Until then, you can join Our Brand new Discord to learn more about the project :

Take care and keep building belts !

Touhma

Updated: