在Unity中,如何实现动态更新导航网格区域的位置。

huangapple go评论140阅读模式
英文:

In Unity, how to have a navmesh that dynamically update the location of areas

问题

我正在尝试制作一个2D顶视游戏,玩家需要移动障碍物来阻止敌人AI前进,但我需要这些障碍物只阻挡特定类型的敌人。

我尝试过使用Unity的障碍物,但它们会影响到每一个导航网格,所以每个角色都会避开它们(而且我需要将它们设置为"carve",因为如果敌人被困住,我需要他们选择另一条路径)
我考虑过创建一个能改变其下方区域而不是切割网格的障碍物,但我没有找到动态实现这一点的方法,而不需要重新烘焙整个导航网格。

是否有办法实现这一点,或者是否有插件可以提供这些功能?谢谢。

英文:

I am trying to make a 2d top-down game where the player moves obstacles in order to block enemy AI from advancing, but I need the obstacles to only block certain types of enemies.

I've tried using Unity obstacles but they carve through every navmesh so every Agent will avoid them (And I need to set them to carve because I need enemies to take another path if they are stuck)
I've thought about having an obstacle that change the area beneath it instead of carving through the mesh, but I haven't seen any ways to dynamically do that without baking the whole navmesh again.

Is there any way to do that, or a plugin that could give me those features ? Thank you

答案1

得分: 0

你绝对应该查看A*寻路项目。在使用了这个之后,我真的无法再回到使用Unity内置的导航网格系统。

https://arongranberg.com/astar/

https://youtu.be/46qZgd-T-hk

他们内置了针对你这种类型情况的解决方案,即有不同的AI层/组。

如果你想尝试的话,有一个免费版本可用

https://arongranberg.com/astar/download

这是免费版和专业版的比较

https://arongranberg.com/astar/freevspro

英文:

You should definitely check out the A* Pathfinding Project. After using this I really can't go back to using Unity's built-in navmesh system.

https://arongranberg.com/astar/

https://youtu.be/46qZgd-T-hk

They have built in solutions for exactly your type of situation, ie. there are different layers/groups of AI.

There is a free version available if you would like to try it out

https://arongranberg.com/astar/download

Here's a comparison between Free and Pro

https://arongranberg.com/astar/freevspro

huangapple
  • 本文由 发表于 2023年6月19日 16:28:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76504906.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定