AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

fromJSON

该方法用于从JSON对象中读取FollowPathBehavior的配置信息。

参数

  • json:包含FollowPathBehavior配置信息的JSON对象。

返回值

无。

使用示例

//实例化FollowPathBehavior
var followPathBehavior = new Yuka.FollowPathBehavior();

//配置JSON字符串
var config = '{"path": [{"x": 0, "y": 0, "z": 0}, {"x": 0, "y": 1, "z": 0}, {"x": 0, "y": 2, "z": 0}], "radius": 2}';

//将JSON字符串转换为JSON对象,并传入fromJSON方法进行配置
followPathBehavior.fromJSON(JSON.parse(config));

配置项

  • path:存储路径点坐标的数组,每个点由一个对象表示,包含三个属性:x、y和z。
  • radius:路径跟随者和路径之间的半径。如果路径跟随者现在在路径的另一端,则该半径会影响其是否会在路径的下一个点之前停止。

注意事项

  • path 数组中必须至少包含两个点。
  • radius 必须是大于或等于零的数字。