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

该方法用于判断当前车辆是否能够触发指定的触发器。

语法

vehicle.canActivateTrigger(triggerName)

参数

  • triggerName: 字符串类型,表示要判断的触发器名称。

返回值

返回布尔值类型,表示当前车辆是否能够触发指定的触发器。如果车辆能够触发,则返回true,否则返回false

示例

// 判断车辆是否能够触发“checkpoint1”触发器
var canActivate = vehicle.canActivateTrigger("checkpoint1");
if (canActivate) {
  // 车辆可以触发此触发器,执行相应的操作
} else {
  // 车辆无法触发此触发器,执行相应的操作
}

注意事项

  • 该方法仅返回车辆当前的触发状态,并不会修改触发器的状态。如果需要改变触发器的状态,需要调用setTrigger方法。
  • 如果指定的触发器不存在,该方法会返回false