学习unity的path finding

in STEEM CN/中文4 years ago

path1.png

大家好,很久没有动unity了,这个是一个写游戏的引擎,很久以前我想用unity做path finding是非常辛苦的,需要写几千行的代码,非常麻烦,现在他们已经把path finding放进去了,非常方便

path finding是在迷宫里找最短的路线

path2.png

首先在window下面,选AI里的navigation

path3.png

navigation的tab出来后,你就可以把全部墙壁和地板打钩navigation static,就可以让电脑知道这些墙壁是阻挡物,找路时候要绕过去

path4.png

全部打钩完成后,就可以到navigation tab里面的bake tab里按bake,电脑就会计算可以走动的地方,也就是蓝色的地方

最后,只要把人物加上component NavMeshAgent, 再set destination,按run人物就会自动用最短的路线,饶过所有的墙壁走到终点

实在太方便了

谢谢阅读

Sort:  

This post has been manually curated by the Decentralised Sustainable EcoSystem movement by various stake holders and charitable donors to support Entrepreneurs favouring a stable STEEM ecosystem

 

I always see a development tool that says "build", never "bake" before. This is interesting indeed.

你那里天气如何?想来玩目前STEEM上最火爆的drugwars游戏吗?还在等待什么?赶快加入战斗吧!drugwars.io倘若你想让我隐形,请回复“取消”。

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 60340.89
ETH 2615.66
USDT 1.00
SBD 2.56