Variables in Actor and/or Blackboard

wilberolive
Wed, 21 May 2025 22:30:58 +0000
AI

As I’m developing my AI, I’m running into an issue where I find myself duplicating variables between the AI’s actor and it’s blackboard. For example, my AI has a variable that keeps track of an object (type of actor) relating to its current task. I need to know this in both the actor’s blueprint and also in the behavior tree. So I ended up with a variable in both. The issue is that I have to keep then in sync. If one is changed, I need to change the other. I can see this becoming an issue as the AI grows with more variables and more edge cases.

These are the options I can think of.

1. Use a Get/Set function on each variable in the blueprint. In the Set function, update the blackboard variable. The only catch with this, is you have to make sure you always use the Set function, and never accidently set the variable directly. There is no way in blueprint to “protect” the variable from this. I also don’t like the idea of ending up with dozens of get/set functions clogging the blueprint.

2. Abuse OnRepNotify, which would eliminate the Get/Set functions above, and provide the same functionality without worrying about setting the variable directly. This feels dirty though.

3. Store the variables only in the blackboard and then have the blueprint get/set the blackboard values only. I just don’t know what the overhead involved is with getting blackboard values every time you need them in blueprint. Anyone know? For example, if you need a type of actor, blackboard can only store Object, so you have to get that and cast to your actor in blueprint. The other issue is all the nodes involved and having to get values by key names (yuck).

4. Store the variables only in the blueprint and have the blackboard get/set these variables directly. This seems like the cleanest approach, however I’m not sure what the overhead is with running a service in the behavior tree that is constantly checking a value of a variable from the actor’s blueprint, instead of just monitoring a blackboard value. If I go this path, then what is the point of the blackboard? I may as well not use it at all.

How do you handle shared variables between the AI actor and its blackboard? Is there another option I’m not thinking of?

4 posts - 2 participants