主题
SkeletalSocketMount
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
- [SkeletalSocketMount](3 属性)
继承成员
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
- 属性:
骨骼挂点用于在角色骨骼上定义附着位置;通过挂点名称、位移和旋转控制其子对象相对目标骨骼的姿态。
适用场景
用于把武器、装饰物或特效挂到角色的指定骨骼,并让这些子对象随骨骼动画同步移动。
使用要点
创建 SkeletalSocketMount 并将 Parent 设为目标角色,设置 SocketName、SocketOffset 和 SocketRotation,再把需要附着的对象设为该挂点的子对象。
注意事项
SocketName 必须匹配角色骨骼树中的有效名称,否则挂点无法正确附着。销毁附着对象或角色时,应按实际生命周期同步清理挂点。
代码示例
把装饰物挂到角色骨骼点
lua
-- @runtime server
local world = game:GetService("World")
local players = game:GetService("Players")
local player = players:GetPlayers()[1]
if player == nil then return end
local character = player and player.Character
if character == nil then
print("当前没有可挂载的角色")
return
end
local socket = world:CreateUnit("SkeletalSocketMount", {
Parent = character,
SocketName = "ugc_tou",
SocketOffset = Vector3.New(0, 2, 0),
SocketRotation = Quaternion.FromEulerAngles(0, math.rad(98), 0),
})
local units = world:CreateAsset("official://preset/105205")
local child = units and units[1]
if child ~= nil then
child.Parent = socket
end属性 (3)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
SocketName | String | "" | 指定要挂载到的骨骼挂点名称。 |
SocketOffset | Vector3 | [0, 0, 0] | 挂点相对于骨骼插槽位置的位移偏移量。 |
SocketRotation | Quaternion | [0, 0, 0, 1] | 挂点相对于骨骼的旋转偏移,使用四元数表示。 |
