主题
PrismaticConstraint
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
- [PrismaticConstraint](17 属性)
继承成员
1 个来源 / 4 属性 / 25 函数 / 6 事件
- 来自 Unit(4 属性 / 25 函数 / 6 事件)
- 属性:
AssetId、Name、Desc、Parent - 函数:
ClearAllChildren、GetChildren、GetDescendants、IsAncestorOf、IsDescendantOf、FindFirstAncestor、FindFirstAncestorWhichIsA、FindFirstAncestorOfClass、FindFirstChild、FindFirstChildWhichIsA、FindFirstChildOfClass、HasChildren、GetChildCount、GetChildAtIndex、SetAttribute、GetAttribute、GetAllProps、Clone、IsA、Destroy、GetPropertyChangedSignal、GetAttributeChangedSignal、FindFromPath、GetFullPath、GetDebugId - 事件:
ChildAdded、ChildRemoved、DescendantAdded、DescendantRemoving、AncestryChanged、Destroying
- 属性:
PrismaticConstraint 描述两个已绑定 Attachment 之间沿单一轴向滑动的棱柱约束。
适用场景
读取或调整编辑器中已经完成 Attachment 绑定的滑轨、升降机构等结构。
使用要点
从场景中查找预配置的 PrismaticConstraint,再调整限制、速度或目标位置等公开属性。
注意事项
Attachment0 和 Attachment1 使用已存在的 Attachment 实例引用,不要传 UnitId 字符串或数字。物理约束建议在服务端创建和调整;也可继续使用编辑器预配置的绑定。
代码示例
读取编辑器预配置的棱柱约束
lua
-- @runtime server
local constraint = game:GetService('World'):FindFirstChild('MyPrismaticConstraint', true)
if constraint == nil or not constraint:IsA('PrismaticConstraint') then return end
print('棱柱约束是否启用:', constraint.Enabled)属性 (17)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
Enabled | Bool | true | 是否启用约束。 |
Attachment0 | Attachment | - | PrismaticConstraint(棱柱约束)连接关系中的第一个附件。该属性用于指定约束这一端所绑定的 Attachment 单位,与 Attachment1 共同构成约束两端与部件之间的连接关系。 |
Attachment1 | Attachment | - | PrismaticConstraint(棱柱约束)连接关系中的第二个附件。该属性用于指定约束另一端所绑定的 Attachment 单位,与 Attachment0 一起确定约束所连接的两个部件端点。 |
LimitsEnabled | Bool | false | 是否启用线性移动范围限制。 |
LowerLimit | Float | 0.0 | 线性移动的最小位置,单位为空间单位。 |
UpperLimit | Float | 5.0 | 线性移动的最大位置,单位为空间单位。 |
Restitution | Float | 0.0 | 约束的弹性系数,取值范围 0 到 1。 |
ActuatorType | Int | Enums.ActuatorType.None | 驱动类型,决定约束的运动方式。 |
Velocity | Float | 0.0 | Motor 模式下的目标移动速度,单位为空间单位/秒。 |
MotorMaxForce | Float | 0.0 | Motor 模式下的最大驱动力。 |
MotorMaxAcceleration | Float | 500000.0 | Motor 模式下的最大加速度。 |
TargetPosition | Float | 0.0 | Servo 模式下的目标位置,单位为空间单位。 |
Speed | Float | 0.0 | Servo 模式下的目标移动速度,单位为空间单位/秒。 |
ServoMaxForce | Float | 0.0 | Servo 模式下的最大驱动力。 |
LinearResponsiveness | Float | 0.0 | Servo 模式下的线性响应系数。 |
Active | Bool | false | 当前约束是否处于激活状态。 |
CurrentPosition | Float | 0.0 | 当前滑动位置,单位为空间单位。 |
