Download

Behavior tree Service intervals broken?

This was previously asked by others in the Answers hub back in October, I’m reposting as it’s unresolved:

The service interval attribute on BT services doesn’t actually seem to do anything! Try creating a service which just prints a string, no matter how high you set the tick interval the service continues to print a string every ‘real world’ tick, i.e without using the prescribed interval at all.

An older thread from answers hub: Service node interval not working as intended? - UE4 AnswerHub

My services are blueprint based so I’m not sure if few of us have found a bug that only affects Blueprint based services. I’m currently mitigating this by forcing a delay inside my service to my desired interval size but obviously that’s a crude workaround.

PS: I’m able to reproduce this in both 4.5 and 4.6 preview

Thanks to Grogger for pointing me to the solution here - BT Service Ticks every frame 4.5 & 4.6 - UE4 AnswerHub

Gist: If your BT doesn’t have any tasks to run it will keep running the Search Start event which in turn triggers Receive Tick. This can be avoided by explicitly implementing ‘Event Receive Search Start’ in your service (even as an empty impl) and your Event Receive Tick will be called at prescribed intervals.

I think this is major gotcha for new BT users as many BT uses cases involve waiting for the AI to see something and then react meaning the BT won’t have any task to run most of the time. Unless people know before hand they need to override Search Start their services are going to run potentially expensive calculations every single tick!

Case in point, even the example in the BT documentation runs the Argo service every single tick (instead of the prescribed ‘tick every 0.5s’ setting) because it doesn’t override Search Start. I suspect many people are building their BTs off this example and won’t realize their service is running way too often.