Multiple UBTTaskNode/TickTask function is not executing simultaneously

I Have created a UBTTaskNode derived class and used TickTask function to move the character every frame.

Problem is when I Spawned that AI Character into the world it is moving smoothly but if I duplicate it only one character moves for 5seconds then stops then the other character moves. I have converted the code to Blueprints and both the AI’s are moving simultaneously.

Where did you store the reference to the actor you’re moving?

It should be Node Memory (the uint8* param passed into ExecuteTask, TickTask, etc).

I could see this happening if you were keeping the reference as a class member as opposed to node memory.

Thanks for the replay @imakevideogames .

My issue got resolved once I have added “bCreateNodeInstance = true;” in the constructor.

I am still trying to understand if there are any better ways to achieve the same by using NodeMemory as I have never used them before.

Ah, thanks, that’s helpful to know. I’d never thought about bCreateNodeInstance before but yet this makes sense.

The C++ BTree classes are more like configuration templates. They’re supposed to be used as read-only config/set-up. Instance memory for the individual nodes is supposed to go into NodeMemory, that’s where each instance running in the trees stores it’s Read/Write data.

If you try to store read/write info as a class member, multiple nodes are going to share those values. bCreateNodeInstance apparently changes the behavior to allocate a new class instance for each node. Slight memory/performance penalty, but useful in certain cases.

Glad to hear it’s fixed!

1 Like