Boid Algorithm
Unleashing the Horde in Unreal Engine
Alright, let's dive into the world of zombie hordes in gaming without making it sound like a high school science project or a scene from Shakespeare. We're talking about a bunch of undead folks meandering around like they've lost their way to the local mall. But here’s the kicker: we’re organizing this chaos in Unreal Engine using something called the Boid algorithm. Yes, “Boid”, not “Bird”, though it’s about birds... sort of.
A Bit of History
First off, a quick history lesson that won't bore you to death. The Boid algorithm was cooked up by a guy named Craig Reynolds back in 1986. He was looking at birds flying together and thought, “How do they do that without crashing into each other?” So, he broke it down into three simple rules: separation (don’t bump into your neighbor), alignment (keep up with the Joneses), and cohesion (stick together, but not too close). And voilà, the Boid algorithm was born, helping computer-generated creatures move in flocks or swarms without turning it into a mid-air bumper cars scenario.
Why It Works?
Stick Together: Zombies try to stay with their group but not too close. It's like, "Hey, I want to be with you, but I need my space, okay?"
Don't Bump Heads: They also try not to crash into each other. If one gets too close, it's like, "Whoa, buddy, personal space!"
Follow the Leader: They all try to move the same way. If most zombies are going left, then every zombie starts thinking, "Left sounds good!"
And the coolest part? You can tweak how much they follow these ideas, like making them stick together more or less. It's like being a zombie boss!
Unreal Engine Meets the Horde
Fast forward to now, and we're applying this to zombies in Unreal Engine. Why zombies? Because watching a horde of them moving together with a purpose is both terrifying and fascinating. It's like they've got their own twisted version of GPS navigation. Using Unreal Engine for this is a no-brainer (pun intended) because it gives us the tools to bring our undead friends to life with stunning graphics and smooth movements.
This Horde System is going to be part of my NeuroAI (Neuro AI is basically High Professional BT system which is heavily multithreaded, and based on some of the most performant algorithms).
The Networking Conundrum
Now, here’s the brain-teaser: how do you keep a game running smoothly online when you’ve got hundreds of these boids, I mean zombies, on screen? If you tried to update every single one in real-time over the network, you'd crash faster than a zombie hitting a closed door. The solution? Be smart about what you replicate. You only send over the important stuff, like where the lead zombies are heading, and let each player's game figure out the rest. It’s like giving out just enough directions to get everyone to the party without having to micromanage every step they take.
BOID partnered up with, Hierarchical Replication, can be a real game changer for those networking geeks.
Cracking the Code
Diving into the code for this was a mix of excitement and “what have I gotten myself into?” moments. Getting those zombies to follow the Boid rules without walking into walls or each other was the goal. The beauty of it is in the simplicity: with just a few lines of code dictating how these zombies should behave, you suddenly have a horde that feels alive and purposeful. And doing this in Unreal with NeuroAI makes it really easy for me to implement.
So, there you have it. Bringing a zombie horde to life in Unreal Engine with a bit of old-school algorithm magic isn't just about coding; it's about creating an experience that feels organic and terrifyingly real. Whether you're a seasoned game developer or just someone who loves to tinker with code, the possibilities are as endless as a zombie's appetite for brains. Just remember, the next time you see a flock of birds gliding seamlessly through the sky, there’s some serious math at work there. And who knows? Maybe those birds are just zombies with a better sense of direction.
My implementation
Basic, Unreal implementation to help you guys out!
https://github.com/WhyDoICode/BoidAlgorithmUE5.32