Yuka 中的 InterposeBehavior 的 active
属性用于启用或禁用行为。当行为处于激活状态时,它会在每帧更新中执行其逻辑,反之则不会执行。默认情况下,行为是激活的。
behavior.active = value;
value
Boolean
true
表示启用行为,false
表示禁用行为。以下示例演示如何将行为的 active
属性设置为 false
以禁用它:
import { InterposeBehavior } from 'yuka';
const behavior = new InterposeBehavior( entity, target, targetOffset );
behavior.active = false;
当行为被禁用时,行为实例仍然存在于其宿主代理的行为数组中。因此,如果你需要完全删除行为,请使用代理的 remove()
方法删除它。