Can see object doesn't work until i deactivate and activate Ai agent gameobject

Ofonna

New member
So my behavior trees are acting weird and i cant seem to understand what the problem is, i'm spawning objects once my scene starts and expect them to detect players when they see the gameobject but it doesnt work except i deactivate other ai agents with behavior trees aswell, i dont know if there could be a reason for this, please help
 
Last edited:
What does your tree look like? Is Can See Object being reevaluated? What do the Can See Object values look like?
 
What does your tree look like? Is Can See Object being reevaluated? What do the Can See Object values look like?

here is what my tree looks like, i'm just prototyping my ai behavior right now as my game mechanic is already complete.

-> i spawn 4 ai agents with behavoir trees on them
-> but the can see object task doesn't work until i deactivate all of them and reactivate them from the inspector which is weird.
 

Attachments

  • Error 1.PNG
    Error 1.PNG
    119.8 KB · Views: 7
I think that this will take some debugging to determine the cause. If you place a breakpoint within CanSeeObject.OnUpdate can you determine where it is returning false when it should have found the object? With the tag set you'll start going down this branch:

Code:
                } else if (!string.IsNullOrEmpty(targetTag.Value)) { // If the target tag is not null then determine if there are any objects within sight based on the tag

MovementUtility.WithinSight should return true when you'd think the object should be in sight.
 
Top