I’m about to lose my mind
I’m using a service on a sequence node in my behavior tree, and the sequence is currently only connected to a single task in the debugging process. In my service, I’m constantly checking something and turning a bool type variable to true using a blackboard key. In my task, I’m constantly checking if that blackboard key’s value is true and if so, I’ll move on with another algorithm. But in that algorithm, the bot’s exact location when that bool type variable turns to true is important. So before I start implementing my next algorithm, I decided to check if there were a delay between the task detecting the vriable’s value change in my service and the detection of the value change in my task. There were indeed a short delay, so I wrote this code below:
(This code is a simplified version of the real thing, only the crucial aspects are included for it to fit in the screen. In the function named “Func”, I get the bot’s current location and I store it inside the variable named “Result”. The outcome is the same whether it’s inside a function or not. The branch node’s condition is set to a blackboard key which represents that bool type variable I mentioned on the bottom left.)
This almost solves the issue. When I draw spheres after the actual value change in my service and after the detection in my task, they match up exactly!.. most of the time Sometimes, not randomly, just in certain locations for some reason, the spheres are not drawn in the same place. (might be due to the bot’s velocity when it’s passing through certain locations) And interestingly, the inconsistency between the spheres’s locations increase when I adjust the time value of the timer either up or down. Maybe it’s because I use the same timer code for detecting when should that bool type variable should change it’s value, the timer in my service is also set to 0.01 seconds. Is there a resonance going on?
Additionally, the inconsistency is even more intense if I handle the checking of the bool type variable’s value change via the behavior tree, by using a parallel composite. In that case, even using the code I’ve provided is no use.
Can it be possible to detect a blackboard key’s value change instantly? Am I overcomplicating something here? I hope I can get your help on my struggle fellas, so much thanks in advance!