Haytam95
Active member
Hi
Today i've been working with the AI of the enemies in my game. It is going nice (BD is a great tool), but i have found a bug in the conditional Can See Object of the Movement Pack.
My character was being detected even behind the walls, so doing a little debugging i found out the problem:
(MovementUtility, line: 114) This function will return the targetObject if the raycast hits him (Or a child / parent gameobject). Null otherwise.
Then a little above (Line 104)
You can see that, if the "LineOfSight" returned null (So the raycast hit another thing or simply nothing), then it will check if the player has a collider. If not, then he assumes than he can see the object. (UCC collider is in a child component called Coliders)
The problem is, that LineOfSight doesn't return another gameobject that isn't the target. So if the targetGameobject doesn't have a collider it will assume that he can see it.
I resolved the problem by removing the else statement as a patch. Probably the best solution is make LineOfSight return the gameObject that have been hitted and check if the returned value is targetObject. Then if it's null, check if the target object has collider.
That's it!
Today i've been working with the AI of the enemies in my game. It is going nice (BD is a great tool), but i have found a bug in the conditional Can See Object of the Movement Pack.
My character was being detected even behind the walls, so doing a little debugging i found out the problem:
(MovementUtility, line: 114) This function will return the targetObject if the raycast hits him (Or a child / parent gameobject). Null otherwise.
Then a little above (Line 104)
You can see that, if the "LineOfSight" returned null (So the raycast hit another thing or simply nothing), then it will check if the player has a collider. If not, then he assumes than he can see the object. (UCC collider is in a child component called Coliders)
The problem is, that LineOfSight doesn't return another gameobject that isn't the target. So if the targetGameobject doesn't have a collider it will assume that he can see it.
I resolved the problem by removing the else statement as a patch. Probably the best solution is make LineOfSight return the gameObject that have been hitted and check if the returned value is targetObject. Then if it's null, check if the target object has collider.
That's it!
Last edited: