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

removeSubgoal

该方法用于将一个子目标从复合目标中移除。

语法

CompositeGoal.removeSubgoal(subgoal)

参数

  • subgoal: 要从复合目标中移除的子目标。

示例

以下示例展示了如何使用removeSubgoal方法从复合目标中移除一个子目标:

const compositeGoal = new Yuka.CompositeGoal()
const subgoal1 = new Yuka.Goal()
const subgoal2 = new Yuka.Goal()

compositeGoal.addSubgoal(subgoal1)
compositeGoal.addSubgoal(subgoal2)

console.log(compositeGoal.subgoals.length) // 输出:2

compositeGoal.removeSubgoal(subgoal1)

console.log(compositeGoal.subgoals.length) // 输出:1

在上述示例中,我们首先创建一个CompositeGoal,然后添加两个子目标。接着,我们输出复合目标的子目标数,以验证子目标是否添加成功。然后,我们使用removeSubgoal方法将一个子目标从复合目标中移除,并再次输出子目标数来确认子目标是否成功移除。

异常

如果传递的参数不是复合目标的子目标,则该方法将抛出一个Error

参考