I am using unity 6000.0.30f1. I am using behavior 1.0.7.
Originally I was using a behavior event instead of the ChecksIfAttackTriggered script. But the issue I would have is that there was about a 1/5 risk of the attack event not being read by the unity behavior graph. I debuggged and could see the debug log of the event getting called from the script, but sometimes the unity behavior graph would just not notice the event? The event would work for the most part, but about 1/5 times times it would just not notice that the event had been triggered.
This was my setup:
Now instead, when the animation event is triggered in unity, that changes a bool to true. The behavior CheckIfAttackTriggered then checks if the bool is true, and if so the behavior succeeds and then moves on to another behavior that set the bool false again.
Here’s a picture:
Now… the strange part is that sometimes i can see my “succeds behavior” debug log, so I know that the status was set to Sucess. I can also see through debug logs that my bool was set to true and then to false again. So I know that the graph did move on to the next behaviors. And yet, the currentState is not changed, it doesn’t reach the final part of the branch, and the behavior tree gets stuck on the CheckIfAttackTriggered, because the bool is false again. This bugg happens about 1/10 times and I don’t understand what’s happening, because it works fine for the most part.
You should upgrade to 1.0.10. In adddition to numerous improvements, a new “Queue” mode was added to StartOnEvent and sounds like what you need:
We’ve added a new Queue mode for the StartOnEvent node that preserves and processes messages sequentially. This is particularly useful when you need to preserve messages when multiple events are received in a single frame.
In regards to your issue, there doesn’t seem to be anything wrong with what you shared. Maybe add a LogMessage node before and after your Set currentState to Chase to ensure both are reached.
The issue still seems to persist for me in 1.0.10. Both when I use the “Wait for Event Message” and the new “StartOnEvent” node with “Queue” selected. Still, the console log is registered, signaling that the event got called, but the branch does not continue all the way through. The bug still only happens some of the time for both methods. I am not sure that I am using “StartOnEvent” correctly though, and I wonder if there are any example use cases?
It seems as though my graph realizes the event has been called and then the debug log is called. But before my graph reaches the next nodes in the sequence, the graph starts over from the parent and realizes that the event is not being called anymore. Which in turn causes my agent to freeze up because it never exits its state. Could this be a feature or a setting that I am using incorrectly?
Another question of mine is whether or not the size of the graph can influence how likely it is to follow all the way through? I have quite a big graph.
Looking at your original graph, I can see that you use Run In Parallel Until Any Succeeds. Could it be possible that your Agent's Head Look At at Target node returns success before your left branch has time to finish?
It’s going to be hard to provide you with a meaningful solution from the provided information because we have to work with assumption. Could you for instance record a session of debugging an agent’s graph and so we could see what’s happening?