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

Active

描述

OnPathBehavior中的active方法用于激活当前路径。

语法

yuka.OnPathBehavior.active();

参数

无参数。

返回值

无返回值。

使用示例

const entity = new yuka.Entity();

const path = new yuka.Path();
path.add( new yuka.Vector3( 0, 0, 0 ) );
path.add( new yuka.Vector3( 1, 0, 0 ) );
path.add( new yuka.Vector3( 2, 0, 0 ) );

const pathFollowing = new yuka.PathFollowingBehavior( path );
entity.steering.add( pathFollowing );

// 激活路径跟随行为
pathFollowing.active();

注意事项

  • 必须在将路径跟随行为添加到实体后才能使用active方法。

  • 如果在路径跟随行为未使用completeBehavior属性的情况下,active方法将导致实体无限追踪路径。若要在到达路径的末端时停止行为,则需要设置completeBehavior属性。

  • 此方法只在路径跟随行为中可用。如果在其他行为或组件中调用此方法,则无效。

  • 可以使用active方法来切换实体的行为模式,例如在巡逻行为和攻击行为之间切换。