"Shaky" path when using Offset Simple Smooth Modifier

That happens because the agent cannot accelerate infinitely quickly, so it overshoots a bit before getting onto the new path. To reduce this you could either reduce the acceleration of the agent (will make it adjust its velocity slower, which will make it smoother, but it may make the overshoot larger), or you can increase the pick next waypoint distance which will make it follow the path in a smoother way (you can debug this by enabling ‘always show gizmos’ on the AIPath script).

OK that makes sense. I’ll fiddle around with that value, though increasing it results in more corner cutting, so I’ll have to find a medium.

I’m now recalculating the physics of an area where my door opens, but the issue is I want the collider to only be on for the cast. Obviously turning it on and off before the physics update is the idea, but I believe the physics checks are delayed, so this doesn’t actually work. Is there another way I could do this? Or even force a wait until the recast has occurred?

You can use AstarPath.active.FlushGraphUpdates() to make sure any pending graph updates are done immediately.

Sounds like a layer mask and perhaps adjusting the global physics layer-layer collision matrix might be helpful.

Yes this is what I’ve gone with and it seems to be working quite well. Though when a door is opened, I see all of the non-walkable nodes toggle on and off (with Show Grid enabled). Is this just because any part of the grid is being updated? Or does this imply I’m accidentally recalculating the whole grid? This is the code I’m using:

if (CurrentDoorState == DoorState.Open) {
    BoundsPathfinding.gameObject.SetActive(true);
    AstarPath.active.UpdateGraphs(BoundsPathfinding.bounds);
}

Is the graph update always delayed? As I am using the bounds of the collider, but if I disable the collider before passing it to the UpdateGraphs method the size is zero. So I need to not disable it until I use its bounds. Can I rely on the UpdateGraph waiting?

(Edit: Actually I can just cache them before disabling, silly me.)

That’s because it cannot draw the unwalkable nodes while the graph is being updated (it might contain invalid information). The graph surface visualization is cached and will be drawn anyway, but the unwalkable nodes currently aren’t so they will disappear for a frame usually (I think in 4.2.x they shouldn’t for grid updates though… but maybe I remember it incorrectly).

It is not explicitly documented, but it will at least wait until the next time the Update method runs on the AstarPath script.

I’m only on 4.1.16, so that might explain the unwalkable nodes disappearing!

It all seems to be working perfectly now, thanks so much for your help!

1 Like