Making a large Battle Simulator game with Bevy and Rust

preview_player
Показать описание
#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!:

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)
♪ Biscuit (Prod. by Lukrembo)
♪ Onion (Prod. by Lukrembo)
Рекомендации по теме
Комментарии
Автор

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.

bipedpotato
Автор

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.

vitasartemiev
Автор

That so cool. I bet it not easy to run smooth for many units in game.

darknetworld
Автор

Great video! It would be nice if you explained the last part where you add shooting with some code and drawings

itzhakeretzkdosha
Автор

You could also create a low poly tank and LOD the instances based on distance from the camera.

NOFAC
Автор

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).

morkallearns
Автор

I wonder if you could further improve on the quad tree idea using adaptive volumetric fluid simulation methods: Do you really need to calculate the precise movement of every single unit stuck in the center of a large crowd? Maybe it's possible to approximate via clusters.
That way, the quad tree would have the opposite behavior: Large chunks of crowd would count as a single multiunit that can only move more or less in lockstep. No need to calculate every single collision there. The closer to "the surface" (the frontline, the backline, the flanks) you get, the finer the grid as motion is less restricted.
One tricky bit there is how to calculate individual positions from the summarized one without generating more work than was saved in the first place, but I suspect it might be possible.
You'd also have to be able to quickly recalculate based on selection but I think that's already a problem now so you probably already solved that

Kram
Автор

thanks for sharing! traversing quad trees sounds super interesting

peterhayman
Автор

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 =
(I did not define instance_index myself. it's built in to the vertex input)

nihil
Автор

2:15 O(n²) is quadratic, not exponential ;)

ArnaldurBjarnason
Автор

Super cool! Sorry if I missed it, but are you using a custom physics engine? Or are you using a crate?

thedevblog
Автор

always happy to see non ai gamedev vids :D

spindlywebs