Skip to content

Sarofc/AStar-Unity2D

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AStar-Unity2D

一个简易的2d寻路方案,基于网格。

Getting Started

  1. 编辑场景,为障碍物设置Layer,并添加BoxCollider2d组件。
  2. 创建一个空物体,添加Maps.cs脚本,配置网格参数(grid size、node size、grid center等),CheckLayer选择layer(障碍物), 点击CreateMapData按钮烘焙网格。
  3. 再创建一个空物体,添加PathRequestManager.cs脚本,将Maps添加进去。
  4. 创建Agent物体,添加Agent.cs脚本,修改Key_provider对应PathRequestManager中的Key;添加Target.cs脚本,指定目标物体,运行。

详情见Example1

Screenshot

烘焙截图,左为烘焙,右为场景

移动方式

  1. Cut Corner

  2. Not Cut Corner

  3. Never(4 direction)

Reference

https://paul.pub/a-star-algorithm/

https://github.com/Epicguru/ThreadedPathfinding

https://github.com/qiao/PathFinding.js

https://www.youtube.com/watch?v=-L-WgKMFuhE&t=180s

https://github.com/BlueRaja/High-Speed-Priority-Queue-for-C-Sharp

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages