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

rotateTo

介绍

rotateTo是Yuka js库中GameEntity类的一个方法,用于旋转GameEntity到指定角度。该方法将GameEntity实例的旋转角度逐步改变,直到达到目标角度。

语法

rotateTo(targetAngle: Number, duration: Number): void

  • targetAngle: 目标旋转角度,单位为度数。
  • duration: 旋转时间,单位为毫秒。

示例

const entity = new GameEntity();

entity.setRotation(0);

// 将实体旋转90度,用时500毫秒
entity.rotateTo(90, 500);

// 将实体从当前角度旋转到0,用时1000毫秒
entity.rotateTo(0, 1000);

备注

如果在执行rotateTo方法时,实体正在旋转,则实体会停止当前的旋转任务,开始执行新的旋转任务。可以通过GameEntity的isRotating属性检查实体当前是否在旋转。