该函数用于判断当前移动对象到达下一个路径点的距离是否小于设定的距离阈值。
nextWaypointDistance (entity, threshold)
entity
:必选参数,移动对象实体。threshold
:必选参数,判断距离的阈值,单位为像素。true
。false
。const entity = new Yuka.Entity();
const path = new Yuka.Path();
// add waypoints to the path
const threshold = 10;
const followPathBehavior = new Yuka.FollowPathBehavior( entity, path );
// other configuration for the behavior
if ( followPathBehavior.nextWaypointDistance( entity, threshold ) ) {
console.log( 'Next waypoint reached.' );
}