A* Pathfinding Project

Enemies move through obstacles


#1

I have my obstacles in a layer named “Obstacle”, and I sat this layer as the obstacle layer mask in the grid settings. When Enemies try to follow their target, the rendered path is avoiding the obstacles but the enemies don’t follow the path. Turning on “Constrain Inside Graph” solves the issue. But I saw a tutorial where enemies were avoiding obstacles without this option. Am I supposed to have that option on or not?


#2

The ‘Constrain inside Graph’ is not required to have this working.
What movement system are you using? Did you make any modifications to translations, and or rotations?
Are you able to reproduce this in one of the example scenes?


#3

I used AIPath the only edit I did was adding this function to the AIDestinationSetter
public void ChangeTarget(Transform newTarget){ if (newTarget != target) target = newTarget; }

I was able to reproduce it in Example15_2D I replaced the AILerp component with AIPath, I changed “Orientation” to “YAxisForward (for 2D games)”. And ran the scene, the AI was moving through obstacles. I tried turning on “Constrain inside Graph” but this time it didn’t fix the issue, the AI was colliding with the obstacles but still not following the path


#4

Hi

Are they not following the path at all or just following it too loosely?
You might want to reduce the ‘pick next waypoint distance’ setting on the AIPath script to make it follow the path more closesly.


#5

Thanks, reducing ‘pick next waypoint distance’ fixed it