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

activateIfInactive

简介

activateIfInactiveCompositeGoal 类的一个方法,用于将一个处于不活跃状态的复合目标激活。当一个复合目标的所有子目标都处于已完成或不活跃状态时,该复合目标将被视为不活跃状态。此时调用 activateIfInactive 方法将使该复合目标重新进入活跃状态。

语法

CompositeGoal.activateIfInactive()

参数

无参数。

返回值

无返回值。

示例

const compositeGoal = new yuka.CompositeGoal();
compositeGoal.addChild( subGoal1 );
compositeGoal.addChild( subGoal2 );

// ...

if ( compositeGoal.isActive() === false ) {
    compositeGoal.activateIfInactive();
}

上述示例创建了一个复合目标 compositeGoal,并添加了两个子目标 subGoal1subGoal2。接着通过 isActive 方法判断 compositeGoal 是否处于不活跃状态,如果是,则通过 activateIfInactive 方法激活该复合目标。

异常

如果没有子目标,方法将抛出异常。

参考链接