Unity reports an error when using NavMeshSetDestination can only be called on an active agent that is on a NavMesh
Cause of problem: NavMesh is not baked
Workaround: Bake the NavMesh interface
Baking method:
Navigation window (menu: Window > AI > Navigation ).
-
Select the geometry in the scene that needs to generate pathfinding - walkable surfaces and obstacles.
-
Select the object that needs to be baked in the NavMesh panel, and check whether Navigation Static is checked.
-
Adjust the bake panel settings according to the size of your agent.
- Agent Radius : How close the agent can be to a wall, window or edge.
- Agent Height : The lowest space height that the agent can pass through.
- Max Slope : The minimum slope that the agent can walk directly on.
- Step Height: The highest height of the obstacle that the agent can step on (walk on).
-
Click the bake button to bake the NavMesh.
Baking success:
A blue grid will be displayed, or a baked resource will also appear in the resource