Welcome back to the The Cowzy Game! This week has been all about setting up and learning about, refactoring my asynchronous loading, behavior trees, and equipping villagers with the right tool & hat for the job! Let’s dive into what’s been accomplished!
Asynchronous Loading
Async loading is the loading of assets dynamically at runtime without blocking the game thread. Rather than preload everything at the start, we can load objects when we need them.
When we select a villager and tell them to do a task, how do we get the game to get villagers to equip the necessary tools?
When selected and a right click event is given, we return information from the right click and begin loading villager assets from the BP Town Manager
Then, the Town Manager checks the tags, and then sends that information to a sequence which begins the async load. When each load is completed, it sets the meshs for the villagers.

When the behavior tree runs, we now begin the change job process, which also calls out behavior tree. Once called, the villagers will now begin their resource collection journey.

Behavior trees
Behavior trees are quite nice to work with so far. They have premade nodes, or you can create your own tasks! I've worked with sequences and played around with delegates, but those aren't shown here.

What I like about behavior trees is that I can easily follow what my individual AI controllers are doing, whether they're stuck in the tree or flowing nicely. I played around with the tree for a bit longer than I expected, but curiosity got the better of me as I wanted to try the premade nodes and my own tasks. Some specific things I've learned:
You can set resource keys to match keys in your blackboard, that way you can tell your Behavior Tree what information you want it to work with. In this case, I'm telling the behavior tree I want to set the resource target (the worked resource), dynamically calculating the acceptance radius the AI knows when it's reached an object and then setting that

Once that runs, the AI then begins its journey to the resource, orients towards it, and then it waits!
Next up on this will be the resource collection!
Right tool for the job
Using Cropout as an example, I've set a static mesh and a skeletal mesh component as a child of the character mesh, ensuring they're set to the correct parent sockets!

Then, Unreal makes it look like the character is actually holding the tool! Kinda cool, eh?
The assets are simply registered as soft objects in a data table where we have a struct Job that contains all the necessary information regarding the job that they are doing. As shown before in the async loading section, we're then loading these assets in when we need them, instead of loading in every single possible tool and outfit for the villagers at load.
What’s Next?
With these systems coming together, the next steps include:
Implementing resource collection: Ensuring smooth interactions between villagers, tools, and resources.
Behavior tree update: Beginning working on the transfer of resources from a resource target to a villager
Christmas!!
Stay Tuned!
Every week brings new challenges and opportunities to grow as a developer, and I’m excited to keep sharing the journey with you. If you’re also working on game development—or just love cozy city builders—drop a comment or message. I’d love to hear your thoughts!
Thank you for following along with The Cowzy Game!
Comentários