Behavior tree only ticks every other frame

I’m currently working on AI and noticed that for some reason the task in my behavior tree only gets called every second frame (see below). This is the case regardless of which event (Receive Execute, Tick AI, etc.) I use to begin the task and also happens in services. The result is that my AI characters do everything only half as fast as the player character. Is there any way to adjust the tick rate for behavior trees?

65272-bt_tick.png

Hello Geckaster,

One thing you could try is to go into your service and in the Details panel, there should be an option called Interval. Adjusting this will change how often your service will tick. If that doesn’t work, could you provide some screenshots of how you are running your behavior tree so I can get a better idea of how you have it set up? Thank you.

Hey there,

thanks for the response. Unfortunately, changing the service’s interval didn’t help.
My behavior tree setup is really not complicated. In my service I get the location of whatever the AI is targeting and then in the task I move the AI there (using physics-based movement).

Just now I put a print node in the player controller, BTTask and BTService to see what would happen and got the following output:

LogBlueprintUserMessages: [BP_BuLPlayerController_C_9] Player controller
LogBlueprintUserMessages: [BTTask_NavigateToLocation_C_1] Task
LogBlueprintUserMessages: [BTService_GetTargetLocation_C_1] Service
LogBlueprintUserMessages: [BP_BuLPlayerController_C_9] Player controller
LogBlueprintUserMessages: [BTService_GetTargetLocation_C_1] Service
LogBlueprintUserMessages: [BP_BuLPlayerController_C_9] Player controller
LogBlueprintUserMessages: [BTTask_NavigateToLocation_C_1] Task
LogBlueprintUserMessages: [BTService_GetTargetLocation_C_1] Service
LogBlueprintUserMessages: [BP_BuLPlayerController_C_9] Player controller
LogBlueprintUserMessages: [BTService_GetTargetLocation_C_1] Service
etc.
Aside from how odd it is that the task is apparently executed before the service, it’s easy to see that it’s just the task being executed less frequently than everything else.

In your behavior tree, under the Details panel when you have your Service selected, click the Show Advanced arrow underneath Random Deviation and then check the Call Tick on Search Start box.

Also, could you recreate this issue in a new project and zip it up and provide a link so that we could look into this issue further? In order to figure out exactly what the issue is, it would be helpful to have a look at your setup more closely. Thank you.

This really doesn’t have anything to do with my setup or even with services. I uploaded a project here but anyone can test it themselves pretty easily.

  1. Create an empty project
  2. Make an actor that prints a text during tick and place it in the level
  3. Make a Behavior Tree Task that prints a text during tick
  4. Make a Behavior Tree that executes only that Task
  5. Make an AI Controller that runs that Behavior Tree, place an empty pawn in the level and give it the AI Controller
    Behavior Tree Tasks, by default, just seem to tick at half the speed of everything else.

Looking at the project you’ve provided, the issue seemed to be the Finish Execute node. Once I removed that node, the BT_Task was ticking properly. You only need to use the Finish Execute node when overriding Receive Execute. In the case of the example you provided, it works just fine without that Finish Execute, and functions as expected.

Thank you!
Removing Finish Execute and using Receive Tick instead of Receive Execute seemed to work.
I was under the impression that you were supposed to use the Receive Execute event, from what I’ve seen in tutorials but I’m glad it’s working now.

There is the problem that sequences don’t seem to work if you don’t end the first task in a Finish Execute node. Currently I can get around this by using a simple parallel instead of a sequence but it’s more of a workaround than a solution.

As far as the Sequence issue, since it is a different problem, you can go ahead and post a new Answerhub topic so we can further investigate the issue and determine if it is functioning as intended. Thank you.

I know this is an old answer, but I’m so confused by it.

How can we use Task nodes with Receive tick properly if we cannot use a Finish Execute with them?

That means that it is impossible to use Tick events for Task nodes with Selectors or Sequences, I believe, because they both need a finish execute with a success or fail result for their tasks.

So basically we cannot use Tick events along with Selectors or Sequences? That definitely doesn’t seem right.

1 Like

Hey Nightmask3,

I’ve taken a look at this, and I’ve been able to successfully set up a custom task that uses Receive Tick and Finish Execute. Could you provide some screenshots of your setup so that I can take a look and see if I can spot any issues if you’re still experiencing an issue?

Thank you so much ! My Tick was happening 3 times for every 1 tick in behavior tree. Now its sorted :smiley: