I have a few very basic AI controllers controlling cities. I’d like to call a global “StartDay” and “EndDay” event in their Behavior Trees, so at the beginning of each day, each city queues it’s tasks, and at the end of the day, it collects the fruits of it’s labour.
My level blueprint has a day/night cycle- how could I use an Interface (or something similar) to trigger all city AI behavior trees’ relevant sequence of tasks? There’s no node to do this in behavior trees that I can find. Could anyone point me in the right direction?
Conceptually you’d have blackboard-observing decorators in your BTs and react to changes to observed BB keys. Changes could be caused by external code pushing values down all the BlackBoardComponents using specific BB asset. The rest would happen automatically.
There’s a new BB feature in 4.7 (that is properly patched up in 4.7.2) that allows you to mark BB keys as “synchronized” which would essentially result in specified key having the same vale across all BB components using it.
Thanks for the response. I was kind of hoping for something like an event so that I can just do the task once. My thought was something like TriggerSunrise->AssignJobs->DispatchWorkers; not like traditional AI that would exist in a state until a condition is met, but rather one that would just do it’s scheduled tasks then wait. Would having something like a boolean for “Sunrise” be capable of triggering a set of events once for each city?
It’s actually pretty easy. Create a custom actor class, in BP or C++, and implement a public “OnSunrise” function. Then, when sunrise comes you just call Get All Actors Of Class and call that function on every one of them. Solved
Sorry, another question… what would be the best way to communicate that function call from my AI to it’s behavior tree? IE when the function is called, the behavior tree triggers a series of tasks?
Sorry, only been on UE4 for a month or so after moving from Unity.