Cowzy Friday: Cows, Troughs, and Behavior Trees ššš
- Wesley Chartrand
- 6 days ago
- 2 min read
Hey all!
This week I spent a lot of time working on getting cows eating, animating, locomoting, and some barn updates as well! I covered a lot of ground so let's get started.
Cows now eat from their troughs!
Troughs Introduced:Ā We now have a BP_AnimalFoodContainerĀ that we can use as a base class for food containers. Currently I have one child, BP_Trough which is used by the barn
All of my food consumption logic is in the base class and we just call that currently.
Food Depletion:Ā Each trough contains a finite amount of feed that depletesĀ as cows eat. When it depletes, I hide the food texture to make it looks empty.!

Animation! Including Cows aggressively eat their food!
I really didn't need to make this, but I wanted to setup my blendspace and eating animation to use to be represented as a montage in the blueprints. There are some benefits to spending time on the animations this setup:
I now have a blendspace to represent the walking to running. It doesn't look great, but that's OK, because these are all temporary assets. What's important is that now I can simply swap everything out when I create them myself.

In my BP_Cow, I can now call my specific animation using the Eat animation montage and run my code as if I had the proper animation.

Cow behavior tree!!
Simply put, cows have a behavior tree! It's rather simplistic so far, but it does exactly what I need to do. If the cow is hungry, it will gets its food source, move to it, and then eat it! If it's not hungry, then they wander around!

Barns create their trough!

When a barn is complete, it will build a trough that is specific to that barn
This is done through an EventDispatch from the construction component!
We do this so every barn has a place for cows to eat
I plan on having trough upgrades and the ability to buy troughs to place throughout the game map!!
What is next!?
I'm going to keep working on my current goal of getting the day flowing as it should. I'm not 100% certain what it will be next but it'll be fun!
Thanks for joining me this Cowzy Friday! Hope you join again soon!!
Comments