Version: 2019.3
Creating a NavMesh Agent
Creating an Off-mesh Link

Creating a NavMesh Obstacle

NavMesh Obstacle components can be used to describe obstacles the agents should avoid while navigating. For example the agents should avoid physics controlled objects, such as crates and barrels while moving.

We’re going to add a crate to block the pathway at the top of the level.

  1. First create a cube to depict the crate: Game Object > 3D Object > Cube.
  2. Move the cube to the platform at the top, the default size of the cube is good for a crate so leave it as it is.
  3. Add a NavMesh Obstacle component to the cube. Choose Add Component from the inspector and choose Navigation > NavMesh Obstacle.
  4. Set the shape of the obstacle to box, changing the shape will automatically fit the center and size to the render mesh.
  5. Add a Rigid body to the obstacle. Choose Add Component from the inspector and choose Physics > Rigid Body.
  6. Finally turn on the Carve setting from the NavMesh Obstacle inspector so that the agent knows to find a path around the obstacle.

Now we have a working crate that is physics controlled, and which the AI knows how to avoid while navigating.

Further Reading

Creating a NavMesh Agent
Creating an Off-mesh Link
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961