How to Assign Task References in Inspector?(BD Pro)

GGyy

New member
After switching to Behavior Designer Pro, I found that I can no longer assign references to other tasks via the Inspector.

C#:
public class A_SeekRandomPos : Action
{
    public A_SeekToTargetPos nextSeekAction;

    public override TaskStatus OnUpdate()
    {
        nextSeekAction.targetPos = ...;
        return TaskStatus.Success;
    }
}

In BD version, I could assign nextSeekAction to another task in the tree using the Inspector.

Questions:
Is this limitation intentional in the Pro version?
Are direct task references no longer supported or recommended?
What is the suggested alternative for targeting specific task instances?

I’m aware of SharedVariables, but direct referencing is sometimes more intuitive and precise for certain setups.
Any clarification would be appreciated.
 
This is possible in the pro version with the [SelectableNode] attribute. With that said, since Action nodes are contained within the Stacked Action node you won't be able to select it. One way around this is to derive from ActionNode instead.
 
Hi @Justin, I have the similar question for BD Pro. I’d like to be able to refer to the task or somehow get it from the script (MonoBehaviour) and execute a function.

I’ve tried some options but no luck here:
Lest say I have An object with BehaviorTree (and MyTask (custom ActionNode task)) and TestScript attached to it. In BD standard I was able to simply assign a BehaviorTree in TestScript in inspector and then find the task by it’s type: behaviorTree.FindTask<MyTask>().MyFunction();. In BD Pro I’ve tried GetTask(index) but wasn’t able to execute function here, also I’d prefer other way if there is any. A’ve also tried to declare a field in TestScript like public MyTask myTask; with [SelectableNode] attribute, but it doesn’t show up in the inspector.

So, is there any way to do this?
 
Upd: I was able to execute a function after finding task using GetTask(index):
C#:
MyTask myTask = behaviorTree.GetTask(index) as MyTask;
myTask.MyFunction();

But, I’ve got the index of my task by calling GetTask and debugging it. Is it possible to somehow set the index for the node, or at least get the index for specific task via scrip (from behaviorTreeData maybe)? (Still this entire method is not the best solution, but at least something)
 
Take a look at the Perform Interruption task for an example of the [SelectableNode] attribute. Maybe your field isn't serializable? With that said, I didn't bring over FindTask from the previous version but I can do so. Now that tasks are primarily within the Stacked Task would you want FindTask to search within that task? I'm guessing yes.
 
Thanks for the reply. I’ve tried making field serializable as well. The problem so far is that [SelectableNode] and [SerializeField] doesn’t work with MonoBehaviour class for me:
C#:
[SelectableNode]
[SerializeField] ILogicNode myTask;
The field doesn’t show up in the Inspector. More than that, if I try to create the same field in my custom task scripts with Action/ActionNode/Conditional class (from BD Pro), it shows NullRef error and BD editor becomes broken. Maybe it’s working only for Entity tasks (with DOTS)?

Do you have any efficient examples referring the task in the MonoBehaviour class?

For me it would be nice to have FindTask within the StackedAction (or if possible to find ActionNode as well, without StackedAction wrapper), or the possibility to assign task in fields with MonoBehaviour class. Not sure which one is easier to implement (and makes more sense) for you.

Really appreciate your response. Please, let me know if I need to create a feature request somewhere.
 
One possible workaround I can imagine myself is maybe to create a custom EntityTask, refer [SelectableNode] within the task and then pass it to the MonoBehavior script from that task. But I know nothing about DOTS and Entity task for now, so I’ll try it tomorrow if that will work.
 
Back
Top