target
是 Yuka js 库中 SeekBehavior
的一个选项,用于定义要追踪的目标。
target
可以是一个 Entity
对象或者一个函数。
Entity
对象,代表直接追踪该实体。Entity
对象,用于在运行时动态定义要追踪的实体。import { Vector3, Entity, SeekBehavior } from 'yuka';
const targetPosition = new Vector3( 10, 0, 0 );
const targetEntity = new Entity( targetPosition );
const agentEntity = new Entity();
const seekBehavior = new SeekBehavior();
seekBehavior.target = targetEntity;
agentEntity.steering.add( seekBehavior );
import { Entity, SeekBehavior } from 'yuka';
function dynamicTarget() {
// 在运行时动态返回要追踪的实体
return someEntity;
}
const agentEntity = new Entity();
const seekBehavior = new SeekBehavior();
seekBehavior.target = dynamicTarget;
agentEntity.steering.add( seekBehavior );