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

canActivateTrigger

MovingEntity类的方法。

该方法检查是否触发了与实体交互的触发器。

语法

MovingEntity.canActivateTrigger(trigger)

参数

  • trigger:类型为Trigger的触发器对象。

返回值

  • 如果实体与触发器相交并且触发器未被激活,返回true
  • 否则,返回false

示例

const entity = new MovingEntity();
const trigger = new Trigger();
const isTriggerActivated = entity.canActivateTrigger(trigger); // 返回false

// 在实体移动后再次检查触发器
entity.move();
isTriggerActivated = entity.canActivateTrigger(trigger); // 返回true

// 激活触发器
trigger.activate();
isTriggerActivated = entity.canActivateTrigger(trigger); // 返回false

备注

  • 该方法只检查实体是否与触发器相交,而不检查实体的类型或状态是否允许它与触发器进行交互。
  • canActivateTrigger()方法通常由实体的控制器调用,以确定实体是否应该在到达触发器前进行交互。

参考