Skip to content

WeldConstraint ​

WeldConstraint 用于描述多个对象之间的刚性连接;当前公开脚本契约只适合操作编辑器中已完成绑定的实例。

概览 ​

WeldConstraint 用于描述多个对象之间的刚性连接;当前公开脚本契约只适合操作编辑器中已完成绑定的实例。

继承自 Unit;可通过 World:CreateUnit("WeldConstraint", ...) 创建;返回单个单位

函数 ​

GetRootUnit ​

签名:GetRootUnit()

获取该 WeldConstraint 所属装配体的根单元,返回值为 BasePart 类型。

读取已配置焊接约束的根单元

lua
-- @runtime server
local world = game:GetService('World')
local weld = world:FindFirstChild('MyWeldConstraint', true)
if weld == nil or not weld:IsA('WeldConstraint') then return end
local root = weld:GetRootUnit()
if root ~= nil then print('焊接根单元:', root.Name) end

属性 ​

名称类型默认值说明
EnabledBooltrue布尔值,表示作者对该焊缝约束的启用意图。默认值为 true,即默认启用;设为 false 可禁用该约束。
ActiveBoolfalse只读布尔值,表示当前焊缝约束是否处于生效状态。该属性用于查询约束的实际生效情况,不可由作者直接修改。
ConnectUnitListArray[]表示该 WeldConstraint 所连接的单元列表的数组属性,默认值为空数组,作为仅服务端创建参数使用。
ExpectRootUnitBasePart-表示该 WeldConstraint 期望的根单元,类型为 BasePart,默认值为 nil,作为仅服务端创建参数使用。