Hi there, I’m trying to have my characters act as Nav Mesh Agents when they’re moving but as Obstacles (with carving) when they’re standing still so that other characters go around them instead of pushing them aside. Each character has both the Agent and Obstacle component on in and it just enables/disables the one that’s required. When I set a destination for the Agent, I also spawn an empty gameObject at the destination point that has a Collider. When the character Collider hits the destination one, it switches from the Agent to the Obstacle as it knows it no longer needs to move.
The issue I’m having though is that when I set a new destination for the Agent, so basically I turn the Obstacle off, turn the Agent on and tell it its new destination, instead of moving from its current location it sort of jitters a little bit to a new position close nearby and goes from there instead. That’s because the Nav Mesh updates itself briefly. Previously, it was being carved by the Obstacle component and now it no longer does that since the Obstacle is diabled.
If I add a 0.25 second delay between disabling the Obstacle and enabling the Agent all works well, but I assume that’s not the proper way to do it. I’ve been searching online for similar posts, however I can’t seem to figure out what the code syntax is to either manually call the nav mesh update so I can place it between the components switch or to add a call-back for when the nav-mesh finished updating so I can enable the agent then.
Can anyone please help? Thanks!