Skip to content

AngularMotorUnit

概览

字段
KindUnit · 单位 Unit
Realmcommon

继承关系

  • Unit(4 属性 / 25 函数 / 6 事件)
    • BaseMotorUnit(10 属性 / 5 函数 / 2 事件)
      • [AngularMotorUnit](1 属性)

继承成员

2 个来源 / 14 属性 / 30 函数 / 8 事件

旋转运动器是驱动场景单位持续旋转的运动组件,通过角速度属性设定旋转速度与旋转轴方向。该类型由场景创建并持有,适合用于自动转动的机关、装饰物或动态展示元素。

适用场景

在需要让物体自动旋转的场景中,例如旋转舞台、风车或旋转门,开发者创建旋转运动器并为其配置角速度即可实现持续旋转效果。

使用要点

通过 game:CreateUnit("AngularMotorUnit", config) 或 World:CreateUnit("AngularMotorUnit", config) 获取实例,其中 config 可传入初始角速度配置。实例创建后可读取或修改 AngularVelocity 属性来动态调整旋转速度与方向。

注意事项

BaseMotorUnit 是各种运动器(Angular/Linear/CurveVel/Pendulum/Waypoint)的基类,运行时不应直接创建 BaseMotorUnit;演示基类 API 时请创建具体子类。通过 IsCycle、BackTracking、HalfCycleTime、ArrivalPauseTime、BackPauseTime 与 Duration 配置循环、返程和时序,再调用 Start/Pause/Resume/Backtrack/Stop 控制运动。运动器通过 OnMotorStart / OnMotorStop 事件回调感知状态。

代码示例

创建旋转运动器并设置角速度

lua
-- @runtime client
local World = game:GetService('World')
local target = World:CreateUnit('WorldUnit', {
    Position = Vector3.New(0, 3, 0),
})
local motor = World:CreateUnit('AngularMotorUnit', {
    Parent = target,
    AngularVelocity = Vector3.New(0, 90, 0),
})

motor:Start()

属性 (1)

Name类型默认值说明
AngularVelocityVector3[0, 0, 0]角速度属性,用于设置或获取角马达单元旋转的角速度。该属性为三维向量,分别对应绕X、Y、Z轴的旋转速度。

关联类型