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

rotation

介绍

rotation 方法是 Vehicle 类的实例方法之一,用于旋转车辆使其朝向指定方向。

语法

vehicle.rotation(angle);

参数

  • angle:类型为 Number,表示车辆旋转的角度。单位为弧度制,逆时针为正方向。

示例

var myVehicle = new YUKA.Vehicle();
myVehicle.rotation(Math.PI/4); // 将车辆旋转45度,即π/4弧度

备注

  • 旋转会在下一次更新(update)时应用。

  • 如果需要立即更新,请调用update。例如:

    myVehicle.rotation(Math.PI/4);
    myVehicle.update(1); // 执行更新操作
    
  • 如果需要在一段时间内平滑旋转车辆,则可使用 rotation.y 属性(类型为 Number),它表示车辆的旋转角度(角度制)。

    myVehicle.rotation.y = 90; // 将车辆转到90度方向
    myVehicle.rotation.y += 1; // 缓慢地将车辆向左转动
    myVehicle.rotation.y -= 1; // 缓慢地将车辆向右转动