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

active方法是SteeringBehavior类的一个成员函数,用于计算并应用该行为对运动物体的影响。

参数

该方法接收一个名为agent的参数,类型为Agent类的实例,表示运动的物体。

返回值

该方法没有返回值。

功能

该方法计算出该行为对运动物体的产生的加速度并应用到物体上,使物体朝着设定的目标方向运动。

使用方法

const behavior = new SteeringBehavior();
const agent = new Agent();

// 设置行为参数
behavior.setTarget(target);

// 应用行为
behavior.active(agent);

示例

const behavior = new SteeringBehavior();
const agent = new Agent();

// 设置行为参数
behavior.setTarget(target);

// 应用行为
behavior.active(agent);

注意事项

  • 在应用active方法之前,需要先通过其他成员函数,如setTarget()等,设置好行为参数。
  • active方法的执行顺序应该按照所使用的游戏引擎或代码框架的规定来确定。一般而言,active方法应该在物体的运动循环中被调用。