beehave icon indicating copy to clipboard operation
beehave copied to clipboard

Behaviour Ticker

Open bitbrain opened this issue 7 months ago โ€ข 0 comments

For larger scenes, there might be dozens or hundreds of behaviour trees that are ticked every single frame. However, especially for behaviours off-screen this can become a CPU performance bottle-neck. Games like Kingdom Come Deliverance 2 implement a system where NPCs are "ticked" at different rates, depending on if they are nearby or further away.

A system like this for Beehave could be possible with the introduction of a new node, something like BeehaveSpatialTicker which would automatically discover all behaviour trees in the scene and manage their ticking (if ticking is set to MANUAL only). In case behaviour trees are not set to MANUAL it will ignore these and exempt them. Optionally, having a new process mode for trees specifically could also be an option (e.g. IDLE_MANAGED and PHYSICS_MANAGED), given we might want to tick them in physics or idle thread but that could also be configured on the ticker itself.

From an implementation perspective, this could be solved in various ways:

  • viewport checks
  • quadtree usage to have gradual tick() frequency

bitbrain avatar Apr 14 '25 06:04 bitbrain