Conditional Abort keeps repeating/looping

appminis

Member
I have a Conditional Abort (Lower Priority) for my tree that happens when the enemy hears the player:
8511afdd0aefebd3185bdb2bcf5266a3.png

https://i.gyazo.com/8511afdd0aefebd3185bdb2bcf5266a3.png


Here are the details for the "Can Hear Object" task above:
1cabe32ffcf441cb148d439800be772f.png

https://i.gyazo.com/1cabe32ffcf441cb148d439800be772f.png


Here is the External Behavior Tree for the above:
7486147581adfde6f7d4dd2f2cf5a59d.png

https://i.gyazo.com/7486147581adfde6f7d4dd2f2cf5a59d.png


When the enemy hears the player, it correctly starts the Heard Player tree. The problem is that when it gets to the end, it then repeats the tree again.
This is the sequence of events:

-Get close enough to enemy so that he can hear the player
-See that the enemy starts his Can Hear tree
-Move the player to a different location and stand completely still (no sound should be emitting)
-The enemy goes to where he heard the player, then starts to wander
-After the wander is completed (using the parallel Wait task shown above), the tree finishes out
-Immediately the Can Hear tree is played again, with the enemy finding the player in its new location

Note that there is no sound being emitted from the player when the tree finishes, and the hearing distance is nowhere close.

What is causing the tree to repeat? Does the conditional abort continue to listen for the player, even though a branch within the tree isn't finished?
 
Last edited by a moderator:
While your external branch is executing can you insert a breakpoint within CanHearObject.OnUpdate to see why it is returning success? Based on what you are saying it doesn't sound like it should return success but setting a breakpoint and stepping through it will definitively say what is happening.
 

So I've tried this:

4926e884b0b77c3a37ea4b5e51ea04a6.png

Full size: https://i.gyazo.com/4926e884b0b77c3a37ea4b5e51ea04a6.png

It looks like the targetObjects.Value is 0, so why would it register as success?

The thing is, the player is making zero noise. To test this, I have a running debug that tells me when the Audio Source on the Player "isPlaying"
When the enemy "hears" the player for the second time, the Audio Source is not playing.

What is strange, though, is if I turn off the Player's Audio Source component in the Inspector during runtime, after he is heard the first time, the enemy does not hear him the second time.

Here is the Audio Source:
4237602bc459ad10501b170ff59bacc4.png



What this seems to say is that the Enemy is recognizing the Player because he has an Audio Source component, even if nothing is playing.
The debug log says that this Audio Source is not "isPlaying" when the Enemy checks CanHear for the second time.

Any idea how that would be possible?

So on Update, I do:

if(audioSource.isPlaying)
{
Debug.LogWarning("AUDIO IS PLAYING!");
}

The debug message appears when I'm walking around. When I am stopped, it no longer shows. After I trigger the Enemy's CanHear for the first time and I run far away, I stand still and wait - checking that my debug audio log message is showing no sound.

As soon as the Enemy finishes his check, he suddenly "hears" my again, triggering his behavior tree.
 
It looks like the targetObjects.Value is 0, so why would it register as success?
You are using the tag/layer so the list returning no values makes sense.

I think that I'll need to take a closer look at this - are you able to send me a PM with a repro scene so I can step through it?
 
You are using the tag/layer so the list returning no values makes sense.

I think that I'll need to take a closer look at this - are you able to send me a PM with a repro scene so I can step through it?

Its a very large project and there are a lot of dependencies, it might be hard to separate out a scene but let me look into that.

Do any of the Can Hear Object task settings look suspect?
46a4b198773c9b67c2d02e2e71cce08e.png


My player has a tag of Player and is on the Player layer.
I do define the actual Target Object shown above (I assign my Player's game object name to that variable during initialization).
Perhaps I shouldn't be using Target Object, Target Tag, and Object Layer Mask and just stick with Tag only?
 
Its a very large project and there are a lot of dependencies, it might be hard to separate out a scene but let me look into that.
It may be easier to start with a new scene and just include a few tasks to try to reproduce it. This would also make it easier for me to look into ;)

Perhaps I shouldn't be using Target Object, Target Tag, and Object Layer Mask and just stick with Tag only?
The underlying logic is the same no matter how you initially get the list of targets. I can't see anything wrong with your task.
 
It may be easier to start with a new scene and just include a few tasks to try to reproduce it. This would also make it easier for me to look into ;)


The underlying logic is the same no matter how you initially get the list of targets. I can't see anything wrong with your task.

I'll try to put something together.
This is a pretty maddening issue - I tried turning off the Audio Source component on the Player before the next check for Can Hear by the Enemy and it STILL returned success! I don't understand how that's even possible.

Even set a Debug Log inside of the BD MovementUtility to tell me when it does its own "isPlaying" checking. Doesn't log anything when I'm standing still, yet Can Hear returns success.

Could it somehow not be clearing the Returned Object from the Can Hear task? That's the only thing I can think of since there's no way it heard it again.
 
Last edited:
I just updated from 1.5.4 to 1.5.5 to see if it would help, but unfortunately got a bunch of errors (Unity 2017.4.12f1) after the import (did not run):

Assets/Behavior Designer Movement/Integrations/Astar Pathfinding Project/Tasks/Search.cs(52,52): error CS1502: The best overloaded method match for `BehaviorDesigner.Runtime.Tasks.Movement.MovementUtility.WithinSight(UnityEngine.Transform, UnityEngine.Vector3, float, float, UnityEngine.GameObject, UnityEngine.Vector3, UnityEngine.LayerMask, bool, UnityEngine.HumanBodyBones)' has some invalid arguments

Assets/Behavior Designer Movement/Integrations/Astar Pathfinding Project/Tasks/Search.cs(52,133): error CS1503: Argument `#5' cannot convert `UnityEngine.LayerMask' expression to type `UnityEngine.GameObject'

Assets/Behavior Designer Movement/Integrations/Astar Pathfinding Project/Tasks/Search.cs(59,56): error CS1502: The best overloaded method match for `BehaviorDesigner.Runtime.Tasks.Movement.MovementUtility.WithinHearingRange(UnityEngine.Transform, UnityEngine.Vector3, float, UnityEngine.GameObject, ref float)' has some invalid arguments

Assets/Behavior Designer Movement/Integrations/Astar Pathfinding Project/Tasks/Search.cs(59,141): error CS1503: Argument `#4' cannot convert `float' expression to type `UnityEngine.GameObject'
 
My suspicions seemed to be correct. The only way I could fix this was by setting the Returned Object variable to Null at the end of the tree sequence. Otherwise, it would always return success. It seems that, for whatever reason, the task checks if there is anything in the Returned Object variable to determine if it is success, but never clears that.
 
That is really strange.. If you can create a repro scene that would be awesome. The only time the returned object is used is when the variable is assigned.
 
Top