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

predictionFactor

简介

predictionFactor 是 Yuka js 库 PursuitBehavior 类中的一个属性,表示预测因子。在追逐行为中,预测因子用于计算预测目标下一时刻的位置。通过调整预测因子的值,可以控制追逐者是否过于保守或过于冒进的问题。

类型

predictionFactor 是一个数字类型的属性。

默认值

predictionFactor 的默认值为 1.0

使用方法

读取值

const pursuitBehavior = new YUKA.PursuitBehavior(target);
console.log(pursuitBehavior.predictionFactor); // 输出 1.0

修改值

const pursuitBehavior = new YUKA.PursuitBehavior(target);
pursuitBehavior.predictionFactor = 0.75;

示例

下面是一个使用 predictionFactor 属性的示例,其中某个实体在追逐其他实体:

const world = new YUKA.World();
const pursuer = new YUKA.GameEntity();
const target = new YUKA.GameEntity();
const pursuit = new YUKA.PursuitBehavior(target);

// 设置 pursuit 的预测因子值
pursuit.predictionFactor = 0.75;

pursuer.steering.add(pursuit);

world.add(pursuer, target);

function loop() {
  // 更新世界状态
  world.time += 16;
  world.update(16);

  // 输出追逐者的位置信息
  console.log(pursuer.position.x, pursuer.position.y);
}

注意事项

  • predictionFactor 是一个常用的参数,需要根据实际需求进行调整。

参考链接