How can I force refresh dynamic variables?

badical

New member
Unity 2021.2.11f1
Behavior Designer: 1.7.2
Movement Pack: 1.5.7
UCC: 2.4.5

How can I force Behavior Designer to refresh (or reload, whatever word works best) all of the dynamic variables? The dropdowns (as well and Variable selecting under Find) continues to show dynamic variables I'm no longer using. This is true after saves, builds, and Unity restarts. Not only is this going to become unwieldy, I'm also starting to suspect something is funky with my project due to it.

I've recently started experiencing some unexpected behavior logic due to some dynamic variables not storing their values for usage later in the tree, and I suspect this may be related to dynamic variables not being cleaned up correctly. I have worked around this by replacing "buggy" dynamic variables with a standard variables, and the behavior tree starts working again as expected. This wasn't always a problem, dynamic variables worked great for weeks, but as I add more, rename some, and stop using others the reliability of them seems to have decreased. The fact that the designer continues to show unused dynamic variables makes me think there's something strange going on behind the scenes- perhaps causing the runtime to also be impacted. I don't have many of them- less than 10 so far. But I have iterated on them over the weeks, which I feel like has contributed to the problem.

I've tried to reproduce this funky behavior and dynamic variables not cleaning up as I stop using them in a clean project, but haven't been able to. So I suspect somehow I've gotten my Behavior Tree is an unpredictable state. I can share my behavior tree in a DM if that helps.

Sorry that this is so vague, it's been a real challenge to understand what's even happening much less reproduce/describe it :/


Edit: I was able to catch this happening shortly after posting.

In this example, part of my tree is setting the dynamic variable "_hasTarget" to true. But later on, the conditional is evaluating this variable to be false. This unexpected behavior is not deterministic, sometimes it works and sometimes it doesn't- which makes it hard to track down. Replacing _hasTarget with a regular variable would fix this, though.

Shows _hasTarget being set to true, but the conditional evaluating as false (with Inspector for _hasTarget assignment)
_hasTarget set to True.png

Showing Inspector for _hasTarget bool comparison
_hasTarget not resolving as True.png
 
Last edited:
This is really hard to say without being able to reproduce it and step through the code. Can you try to create a new tree and see if you can list the steps for me to reproduce?
 
I understand. I've been trying to reproduce it in a clean setting without luck so far. Will keep trying to dig up more information to help.

I feel like either I'm misunderstanding something about how it should work/is working, or maybe I got this particular tree/project in a funky state and am not sure how to fix that.
 
Top