Collision on AI Object



I have a npc that moves on the scene in a certain moment, and I want to have collision on the npc

When he moves ALONE it’s seems ok, but when my character moves together, the npc start flicking on the scene, like he is colliding with himself.

when I disable the boxCollider2D or change the layer of the ncp, the npc works normal, but without collision, and the player can pas through it.

I’m using Seeker, AI Lerp, AI Destination, Rigidbody 2D, box collider 2d and the DynamicGridObstacle2D on the NPC, and put a different layer that is used for collision on the AStar Class

Is there a way to make the AI and collision work together without making them flickering?

(the npc is that blue box on the top of the screen)



Since you have both a collider and a DynamicGridObstacle component on the ai, the graph will update around it as it moves so it will constantly be making the ground under it unwalkable. I would recommend that you remove the DynamicGridObstacle component from the ai and mark the ai as not included in the collision testing layer mask.


Thx for the answer aron!

But where I can mark the ai as not included in the collision testing layer mask?

If I change the AI on one of those layers that is checked on the list,the AI start having collision, but after 10 secs, the collision update the position and flick a bit to the side
And if I change for one that don’t have the checker, the AI don’t have any collision and the player can pass through it


Don’t know if I did it right
I add a new tag called AI on the AStar Path script at settings > tag name
On the NPC I added the class GraphUpdateScene and use the new tag with the Collision2D on it.
On the player at Seeker, I turn off the check for AI Traversable.

The npc move normally on the scene even the player moving around, but some times he does a flicking because of the collision on the grid, and it take some seconds to update the grid with the npc collision too
Isn’t it suppose the npc to ignore his collision in the AStar and stop flicking?

Something that I missed?

(can I do a double post? if not, i’m extremely sorry! and i will edit my previous post)


Finally I got it!!!

what i missed:
I put the layer of the npc as a blockable passage, so when the npc moves and the collision update, it flicks to the side, so i just change the layer and use the default make working normal!
there is only one little thing that bothers me
when the npc moves through a passage, and I click for the player to pass that passage too, the player can pass throught it together with the npc, maybe because it didn’t updated yet for the player to not move to there

any ideia to fix this?