统一定制的纳维梅什障碍地形树?

发布于 2025-02-11 05:28:20 字数 330 浏览 0 评论 0原文

我有一个带有树木的地形,上面烤到了Navmesh中。 NavMesh会自动在树木周围创建一个障碍,但它似乎是基于模型而不是对撞机的。既然我只希望AI躲避树的树干,而不是树枝,那么如何为树木创建自定义的Navmesh障碍物?我尝试在树上添加Navmesh障碍物,但没有做任何事情。这是一个屏幕截图,显示了我的意思:

“

基本上,这太大了,我想要一个太大它要较小,并且能够在其上设置自定义的NavMesh障碍物。

I have a terrain with trees on it that is baked into the NavMesh. The NavMesh automatically creates a barrier around the trees, but it seems to be based around the model, not the collider. Since I only want the AI to dodge the trunk of the tree, not the branches, how can I create a custom NavMesh obstacle for the trees? I tried adding a NavMesh obstacle to the tree, but it didn't do anything. Here's a screenshot showing what I mean:

screenshot

Basically, that's too big of a barrier, I want it to be smaller and be able to set a custom NavMesh obstacle on it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼眸印温柔 2025-02-18 05:28:20

我很确定可以将NavMesh构建源从网格更改为对撞机的选项,但是我找不到它,我想它已从Inspector中删除,但您仍然可以从脚本中生成NavMesh:

Bounds bounds = new Bounds(Vector3.zero, new Vector3(200,20,200);
List<NavMeshBuildSource> sources = new List<NavMeshBuildSource>();        
NavMeshBuilder.CollectSources( bounds, LayerMask.GetMask("Default"),NavMeshCollectGeometry.PhysicsColliders,0, new List<NavMeshBuildMarkup>(), sources );
NavMeshData data = NavMeshBuilder.BuildNavMeshData( NavMesh.GetSettingsByID( 0 ), sources, bounds, Vector3.zero, Quaternion.identity );        
NavMesh.RemoveAllNavMeshData();
NavMesh.AddNavMeshData( data );

I am quite sure there was option to change navmesh build source from mesh to collider but I cannot find it, I suppose it has been removed from inspector but you can still generate your navmesh from script like that:

Bounds bounds = new Bounds(Vector3.zero, new Vector3(200,20,200);
List<NavMeshBuildSource> sources = new List<NavMeshBuildSource>();        
NavMeshBuilder.CollectSources( bounds, LayerMask.GetMask("Default"),NavMeshCollectGeometry.PhysicsColliders,0, new List<NavMeshBuildMarkup>(), sources );
NavMeshData data = NavMeshBuilder.BuildNavMeshData( NavMesh.GetSettingsByID( 0 ), sources, bounds, Vector3.zero, Quaternion.identity );        
NavMesh.RemoveAllNavMeshData();
NavMesh.AddNavMeshData( data );
毅然前行 2025-02-18 05:28:20

如果您想遇到较小的障碍,则可以更改代理大小和重新烘烤。

,如果要修改障碍物,则可以使用NavMesh修饰符,并且可以分配为步行区域,因此NavMesh在烘烤时会忽略此障碍。
https://docs.unity3d.com/2020.1/documentation/manalual/manual/manual/manual/manual/manual/manual/ class-navmeshmodifier.html

If you want to smaller barrier you can change your agent size and re-bake. Here is the agent size settings

And if you want modify the obstacles, you can use navmesh modifier and you can assign as walkable area so navmesh will be ignore this obstacle when baking.
https://docs.unity3d.com/2020.1/Documentation/Manual/class-NavMeshModifier.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文