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

execute

描述

execute 函数用于执行 CompositeGoal(复合目标)中的一个或多个子目标,通常情况下,它应该被包含在 CompositeGoal 中,并从主函数中调用。

语法

CompositeGoal.execute()

参数

此函数没有任何参数。

返回值

如果成功执行子目标,则返回 true,否则返回 false

示例

let myCompositeGoal = new CompositeGoal();
myCompositeGoal.addSubGoal(goal1);
myCompositeGoal.addSubGoal(goal2);
myCompositeGoal.addSubGoal(goal3);

function update() {
  myCompositeGoal.execute();
}

在此示例中,我们创建一个名为 myCompositeGoal 的 CompositeGoal,并向其添加了三个不同的子目标。在主循环中调用 execute 函数来执行这些子目标。

异常

如果 CompositeGoal 对象已经被销毁,则会抛出一个异常。如果子目标返回失败,则 execute 函数总是返回 false