Making a large Battle Simulator game with Bevy and Rust
ฝัง
- เผยแพร่เมื่อ 15 มิ.ย. 2024
- #gamedev #rustlang #bevy
Have you ever wondered how games like Ultimate Epic Battle Simulator are able to have millions of units on screen while running at a relatively fine FPS? Well in this video, I built on one of my previous videos "Remaking my game from scratch in an ECS with Rust and Bevy" where I attempted to create a battle simulator like UEBS. I wasn't very successful in the previous video but by the end of the video, using my newly learned skills in Bevy and Rust, I was able to develop a project that runs at a steady 100+ FPS when having 20k tanks duking it out on the big field. In this video I show you some useful optimizations when attempting to make a battle simulator game such as spatial partitioning through Quadtrees and rendering optimizations using custom render pipeline Shader Instancing with WebGPU and wgsl. I was no where near getting millions of units on screen but I'm pretty happy with this project as a whole! If you like the video make sure to drop a like and subscribe.
Making a large Battle Simulator game with Bevy and Rust
Join my discord!:
/ discord
Time Stamps:
Intro - 0:00
Where we left off... - 1:30
Spatial Partitioning through Quadtrees - 2:30
Explanation of Shader Instancing and tank 3d Model Timelapse - 4:30
How to actually perform Shader instancing - 5:30
Intro to unit combat implementation - 7:41
How to partition quadtree to find potential Combatants - 8:53
Glossing over how much I struggled to implement Combat - 10:58
Outro - 11:07
Music Used:
Chill Wave by Kevin MacLeod
Heroic Age by Kevin Macleod
♪ Marshmellow (Prod. by Lukrembo)
Link : • lukrembo - marshmallow...
♪ Biscuit (Prod. by Lukrembo)
Link : • (no copyright music) l...
♪ Onion (Prod. by Lukrembo)
Link : • (no copyright music) l... - วิทยาศาสตร์และเทคโนโลยี
Subscribe for a "consistent" upload schedule, also I'm aware that this video doesn't have the most elegant explanations, and I guess youtube compression really dislikes this video as well I just wanted to get it out as soon as possible so we don't reach 4 months without uploading.
There is a crate called bevy-spatial. It provides kd-trees that track marked entities as a resource. It supports fast lookups within a radius, nearest neighbor lookups and axis-aligned rectangle lookups (see pull request). It may help you outright or inspire you for your own version.
I've been making grass and am hitting a hard performance bottleneck, so I was thinking about trying a custom render pipeline to implement instancing as well. Fixed update might also be useful. Really cool stuff! Definitely relate to the "messy and inefficient" part, probably will have to rewrite it once I get all the pieces of my game working (gameplay tbd, but building a huge procedurally generated open world).
thanks for sharing! traversing quad trees sounds super interesting
Great video! It would be nice if you explained the last part where you add shooting with some code and drawings
Yeah you are right but the video was getting a bit long, perhaps in another video further down the line?
That so cool. I bet it not easy to run smooth for many units in game.
yeah it was pretty complicated and I’ve only reached the surface of full potential battle simulators like UEBS that can simulate millions of units ON TERRAIN AND WITH ANIMATION without that much lag.
This is really awesome
Super cool! Sorry if I missed it, but are you using a custom physics engine? Or are you using a crate?
its just a simple separation check which is made more performant through a spatial partitioning system through a quadtree. I didn’t use any crates.
Nice, btw is it fully deterministic?
So i would like it to be but as you can probably tell from the last segment of the video, one side should not win by so much with equal units. The combat system is a really hacky system that I whipped up last minute so I didn’t really expect much either. Other than that the rest of the game should be completely deterministic as Its run on a fixed update.
umm.. I think Bevy 0.12 already does batching & instancing for you without a custom shader?
I can render 6.5 million blades of grass with:
var model = mesh_functions::get_model_matrix(vertex.instance_index);
(I did not define instance_index myself. it's built in to the vertex input)
this way i have more control and can remove features that I deem to be useless to my project, also I did not know that instancing was already built into bevy and didn’t want to test it out.
always happy to see non ai gamedev vids :D
I like
same
video is too hard to understand