Voxel Game w/ Bevy #1: Motivation


Prologue

In high school I wrote a multiplayer shooter game that featured fully modifiable voxel terrain called Voxelfield.

After learning more about computer science and getting more comfortable with types, move semantics, macros, memory management, etc. I decided to embark on a more challenging but ultimately rewarding path. I would use Rust! Specifically, the Bevy game engine. The tradeoff being more development complexity in exchange for blazing fast performance.

Motivation

First it may help to explain how I got started with ECS. I found that the callback and OOP oriented code Unity emphasizes is terrible for multiplayer design. Why? Often times in proper multiplayer code you have to rewind the entire world and revaluate movements. This excellent article from Valve explains it in more detail. Eventually I designed my own sort of hybrid library that treated data as first-class citizens. Functions were usually pure and tried to minimize side effects. It was more that I was designing functions around data instead of the other way around.

It turned out my approach was completely missing out on one of the main advantages to ECS: cache locality. Basically accessing bytes at random locations is much slower than if they are close together. And since I was using C# everything was a pointer. I know C# has structs and now records but do to some issues with boxing that are more complicated I could not get a pretty implementation. Furthermore, I was using recursion to descend upon components which ended up being quite inefficient, most likely to do the overhead of calling a function in C#.


site tech

go backend

bootstrap frontend

docker deploy