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

timeLastSensed

timeLastSensed 是 Yuka js 库中 MemoryRecord 类的一个属性,代表记录上一次感知到特定实体的时间戳(或者说时间点)。

语法

let record = new MemoryRecord(entity, distance);
record.timeLastSensed = timestamp;

参数

  • entity:对象类型,表示存储的实体对象。
  • distance:可选数字类型,表示存储的实体与代理的距离,默认值为 Infinity
  • timestamp:数字类型,表示上一次感知到特定实体的时间戳。

示例

// 创建感知对象
let entity = new Object();
entity.position = new Vector3(10, 0, 10);

// 创建代理
let agent = new Agent();
let memorySystem = new MemorySystem(agent);

// 记录实体到记忆
let record = memorySystem.createRecord(entity);

// 感知到实体并记录时间戳
let timestamp = Date.now();
record.timeLastSensed = timestamp;

说明

timeLastSensed 属性被 MemorySystem 类使用,用于实现代理的长期记忆和短期感知机制。当代理感知到一个特定的实体时,通过创建 MemoryRecord 对象并将其存储在存储库中来保存实体信息。当代理再次感知到同一实体时,它将使用 timeLastSensed 属性更新存储的时间戳,以便计算两次感知之间的时间间隔。 MemorySystem 对象可以使用这些信息来根据需要清除或更新代理的记忆。

参考

更多 Yuka js 库的 API 信息可以参考 Yuka API 文档