# Zjbcool-pathfinding
Verge3D自动寻径插件,计算3D导航网格上两点之间的最近路径,并控制角色运动。基于three-pathfinding (opens new window)。
EN
The pathfinding plugin for Verge3D calculates the nearest path between two points on the 3D navigation mesh and controls the movement of the character. Based on three-pathfinding (opens new window).
# load script
用于从CDN加载three-pathfinding.js
库,还可以在.html
文件中使用script
标签加载。
<script src='https://cdn.jsdelivr.net/npm/three-pathfinding@0.14.1/dist/three-pathfinding.umd.js'></script>
EN
Load the three-pathfinding.js
library from CDN. also, you use the 'script' tag in your .html
file to load it.
# create pathfinder
该拼图用于创建Pathfinder实例。
参数:
- obj - 文本(字符串),导航网格的名称,可以使用Blender2.79 (opens new window)的游戏引擎创建,查看Creating a Nav Mesh (opens new window)
- playerPosition - 列表(数组),玩家初始位置
- extraOption - 字典(对象),用于控制玩家属性的额外选项
EN
This puzzle used to create a instance of Pathfinder.
Parameters:
- obj - Text/String, navigation mesh,you can create it using Blender2.79,see Creating a Nav Mesh (opens new window)
- playerPosition - List/Array, The initial position of the player
- extraOption - Dictionary/Object, Extra options for controlling player attributes
# set prop
在一个字典中设置玩家的属性。
EN
Sets the player's attribute in a dictionary.
# get player
根据导航网格获取玩家名称。
EN
Get the player's name according to the navigation mesh.
# teleport player
瞬间将玩家传递到指定位置。
EN
Teleport the player to the specific position immediately.
# calculate path
计算玩家当前位置和指定位置之间的最近路径。
EN
Calculate the nearest path between the player's current position and specific position.
# animate player
沿着计算出的路径将玩家移动到目标位置。
参数:
- speed - 数字,动画的速度
- endDistance - 数字,动画结束时,玩家和终点的距离
- lockUp - 布尔,锁定玩家垂直方向的轴
- obj - 字符串,导航网格名称
- moving:do - 回调函数,当动画播放时执行该插槽下的拼图
- stop:do - 回调函数,当动画结束时执行该插槽下的拼图
EN
Move player to target along with the path calculated.
Parameters:
- speed - Number, the speed of the animation
- endDistance - Number, the distance between player and target when the animation stopped
- lockUp - Boolean, lock the player's vertical axis
- obj - String, the navigation mesh
- moving:do - callbacks, execute the puzzles in the slot when the animation is playing
- stop:do - callbacks, execute the puzzles in the slot when the animation stopped