Up and Running With Bevy + Skein

Up and Running With Bevy + Skein
album cover for "David Comes To Life" by the artist "Fucked Up"

James Phillips

4 min read read

What is Bevy, and why has it become one of my favorite open-source projects? Bevy is a game engine written in rust that uses an ECS (entity, component, system) back end. Unlike popular engines like Unreal, Godot, or Unity, Bevy has no visual editor. It is updated on a quarterly basis and breaking changes occur frequently. There is also a surprisingly large community of community crates that update within 1-2 weeks of a new version.

What draws me most to Bevy is its "hand-rolled" feel. It's simple, minimally opinionated, and leaves me with a rare sense of total creative freedom. This freedom comes at the cost of needing to engineer your imagination or being resourceful with community crates, either of which will send you down beautiful rabbit holes where you will be confronted with managing the raw logic of how your systems will work.

Let's circle back, what is and ECS and why this over traditional game development paradigm of Object Oriented programming. Imagine a massive SQL table where each row is an entity, and each column represents a component. Systems operate like SQL queries, scanning for rows with certain columns and updating their values. And because it’s all in Rust, we get strong types and memory safety, which keeps this mountain of data from spiraling into chaos.

Frankly this model works in my brain and I like it. There is a simplicity and an elegance to it. Since this is all in rust, we have robust types and memory safety to keep this heap of data from spiraling out of control. With that as well, it does feel like you objectively get a little more game with every system you write, organizing your little world into existence. My task completion dopamine cycle has been primed.

I’ve started and abandoned more Bevy projects than I care to admit. For a while, that felt like failure. But in hindsight, each project was really just a stepping stone. I wasn’t building games—I was building features. An orbit camera here, a procedural map there. Each one taught me something. And that slow grind has finally added up to the confidence I have now: I’m ready to finish a game.

So what is my set up and how are we getting cracking. There are 3 crates I currently relying on to get things going. Avian Physics, TNUA, and Bevy Skein. I believe that with these 3 crates alone you can get sooo much done.

Avian Physic's is a physics plugin for bevy and does all the fun stuff you would want from a physics engine. It allows for you to create colliders from meshes, add sensors to thing, create "motorized" objects and so much more. I feel like reading through the documentation of this crate and experimenting with it is an amazing crash course in game physics generally. This crate like many is simply exposing you a plugin to register with you bevy app. Due to this, if you ever have a need, you can go straight into the source code and build a full understanding of how everything your working with is actually running. For the most part, the exposed functionality is more than enough and as long as you set up your project correctly (check the examples, there is a specific scheduling order to avoid tunneling and other undesired behavior!) https://docs.rs/avian3d/latest/avian3d/

Next we have TNUA (https://docs.rs/bevy-tnua/latest/bevy_tnua/index.html). This crate exposes a character controller that ties directly into Avian. This also requires some very specific configuration with scheduling and there is an example to work off of in the documentation to help you get started. My favorite thing so far with this controller is that it just works. With in less than an hour I had a fully functional movement controls with a jump and directional dash. My code for this is simple and easy to read and I am looking forward to further extending it with more complex states. This create also exposes some functionality to integrate with your character animations to help keep everything in sync. I am super excited to tap this functionality in once we move past the block out stage of the game.

Finally we have skein (https://bevyskein.dev/). This one does require nightly rust due to some fancy footwork using some experimental features under the hood, butt what does for your workflow is nothing short of amazing. Rather recently bevy exposed a trpc api from your application that enables remote access to your application. This change was designed to enable developers to create integrations with tools that function as an editor. Skein takes this new feature, matches it with a blender plugin... and the next thing you know your labeling components on your 3d objects in blender which then stash said data in your gltf file to be read by your bevy app. This is an amazing boon to level design workflows and it feels very very good to work with. For instance, take adding terrain with a collider to your game. Ctrl+A add your plane, go down to the skein addon and add the collider component exposed to you via avain3d and boom. You can even set arbitrary values as necessary as well! This does add the ability to brick your build by passing the wrong values, but even then your build errors will point your right back to where you goofed and you'll be on your marry way shortly there after.

So that's where we are today. The majority of last week was spent refining my non-existent blender skills and getting a firm grasp on these core crates I am using to build my game. Hopefully in the next few weeks I can slap together a play testable iteration that I can potentially compile to wasm and expose to you lovely people to get some feedback on! Stay tuned for more updates and I hope you all stay safe in this world gone mad!

Share this post