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

sendMessage

功能说明

给Yuka中的Vehicle对象发送消息。

语法

vehicle.sendMessage( receiver, message )

参数

  • receiverObject,接收消息的目标对象。
  • messageObject,消息内容。

返回值

无返回值。

示例

const vehicleB = new YUKA.Vehicle();
const vehicleC = new YUKA.Vehicle();

const message = { foo: 'bar' };

vehicleB.onMessage = function( sender, message ) {
    console.log( 'VehicleB has received a message from VehicleA:', message );
};

vehicleC.onMessage = function( sender, message ) {
    console.log( 'VehicleC has received a message from VehicleA:', message );
};

vehicleA.sendMessage( vehicleB, message );
vehicleA.sendMessage( vehicleC, message );

异常

如果receiver或message参数未提供或不合法,将抛出TypeError异常。