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函数

removeSubgoal函数是Yuka js库中的一个方法,用于从一个行为树中移除一个子目标节点。

语法

behaviorTree.removeSubgoal( subgoal )

参数

  • subgoal(必填):要移除的子目标节点的引用。

返回值

removeSubgoal函数没有返回值。

示例

const behaviorTree = new BehaviorTree();

const moveToPlayer = new MoveToPlayer();
const attackPlayer = new AttackPlayer();

behaviorTree.root = new Selector([
  moveToPlayer,
  new Sequence([
    new Inverter(new CanSeePlayer()),
    attackPlayer
  ])
]);

behaviorTree.removeSubgoal(moveToPlayer);

上述示例中,首先我们创建了一个新的行为树,然后向其添加两个子节点:moveToPlayerattackPlayer。然后创建了一个选择器节点,作为行为树的根节点,用于选择一个子节点来执行。其中选择器的第一个子节点为moveToPlayer节点,第二个子节点为一个序列节点,该序列节点包含一个取反器节点和一个attackPlayer节点。

最后,我们调用removeSubgoal函数移除掉了moveToPlayer节点。移除后的行为树中只剩下一个选择器节点,该节点会根据条件选择是否执行attackPlayer节点。