[Bug]? Breakpoints don't work on the first tree pass

Bak96

New member
Hi, I'm experiencing an issue where breakpoints do not trigger during the first tree pass when using Behavior Trees.
The debugger simply skips all breakpoints on the initial pass, but starts working normally on subsequent passes (only when Restart On Complete tick is set to true).

I'm using Unity 6000.0.63.f1 LTS and Behavior Designer v1.7.12 (latest).

It happens always, no matter if I enable tree from code or the tree starts itself automatically when entering playmode.
Is it a bug or am I missing something? This issue is quite problematic for me.
 
This is a result of Unity's OnPlaymodeStateChange occurring after the behavior tree is updated on the first tick. There are a couple of ways to work around this:

- Don't have the behavior tree started upon start. You should start the behavior tree at least one frame after Unity enters playmode.
- Add a small delay to the start of the behavior tree
 
I added the code that enables the behavior tree after hitting Space button.

First method - I disable the BehaviorTree component in the inspector before playmode and after hitting space in playmode I enable the component by tree.enabled = true.
This starts the behavior tree, but still breakpoints do not trigger during the first tree pass.

Second method - I disable the whole game object in the hierarchy before playmode and after hitting space in playmode I enable the game object by tree.gameObject.SetActive(true)
This starts the behavior tree, but still breakpoints do not trigger during the first tree pass.

The breakpoints work starting from the subsequent passes, but the first pass is always missed no matter what I try.
 
Ah, I mispoke. It relates to when the behavior tree attaches itself to the editor, which will always be a frame after the tree starts. The breakpoints are only saved within the editor so that's why there is some initialization. If you add a single frame delay to the execution of your tree then the breakpoint will be hit.
 
I added a small delay using Wait block at the start of the tree and the first breakpoint worked. Thank you
 
Back
Top