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

updateRegion

该函数用于更新一个已经注册的活动区域的设置。

语法

Yuka.Trigger.updateRegion(regionId, settings)

参数

  • regionId:类型为字符串,是要更新的活动区域的id。
  • settings:类型为对象,包含要更新的设置属性的名称和值。

示例

// 创建一个名为'region1'的活动区域,并注册到观察列表内
Yuka.Trigger.createRegion('region1', {
  rect: { x: 100, y: 100, width: 300, height: 200 },
  callback: function() {
    console.log('进入活动区域');
  }
});

// 更新'region1'的位置和尺寸
Yuka.Trigger.updateRegion('region1', {
  rect: { x: 200, y: 150, width: 400, height: 300 }
});

设置属性

  • rect:类型为对象,包含区域的位置和尺寸信息,格式为{ x: number, y: number, width: number, height: number }
  • callback:类型为函数,用于指定进入活动区域时的回调函数。函数参数为空。

异常

  • 如果指定的活动区域id不存在,将抛出一个类型为Yuka.TriggerException的异常。