NavigationAgent2D, How would I update the navigation polygon to go around newly introduced Static Bodies

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SwSh

I have the KinematicCharacters with the NavigationAgents on a navigation polygon, but when I add a new static body, I want to update the walkable areas, How would I do that during run time?enter image description here

:bust_in_silhouette: Reply From: SwSh

Okay, so the solution is to update the NavigationAgent2D Safe compute, and just read that instead of directly setting the motion. For further elaboration:
nav_agent.set_velocity((nav_agent.get_next_location()-self.global_position).normalized()*Move_Speed)

Works better than:
Motion=((nav_agent.get_next_location()-self.global_position).normalized()*Move_Speed)