DynamicGridObstacle confuses the NPC

Hey hey,

I have objects called ‘NPC’. These NPCs are in constant movement along a waypoint path until reaching the end or detecting an enemy. Simply because the ‘NPC’ is also an object, I assigned the DynamicGridObstacle script to it. The problem is that it confuses the gameobject and the path created is both trying to reach the target end point as well as avoid its own ‘obstacle constraints’.

What is the way to exclude its own constraints and calculate a smooth path? I am suing GridGraph + AIPath Script

Thank you

Are you using DynamicGridObstacle to keep NPCs from colliding with eachother?
If so, what you need is to implement some sort of local avoidance algorithm. (or buy the Pro version of this asset, which comes with one such implementation ready for use)

The simplest such algorithm is simulating each agent with the same rules as an electric charge, or, in simpler terms: add a force inversely proportional to the distance betweeen each pair of agents, so they push themselves away. This is the method used by Starcraft 2, but makes the units look very floaty and still overlap when going through tight spaces.

A bit more info on better ways to do it: How is RTS local avoidance done?

If that’s not why you’re doing this, please explain your usecase better.

1 Like