Expose SkinnedMeshRenderer bone API to Lua (read/write local transforms)#707
Merged
adriengivry merged 5 commits intoOverload-Technologies:mainfrom Apr 16, 2026
Merged
Expose SkinnedMeshRenderer bone API to Lua (read/write local transforms)#707adriengivry merged 5 commits intoOverload-Technologies:mainfrom
adriengivry merged 5 commits intoOverload-Technologies:mainfrom
Conversation
Contributor
Author
|
Here is the Lua script I used locally for testing : ---@class BoneApiTest : Behaviour
local BoneApiTest =
{
targetBoneName = "mixamorig:Head",
speed = 2.0,
positionAmplitude = 0.03,
rotationAmplitude = 20.0,
scaleAmplitude = 0.05,
logBonesOnStart = false,
_renderer = nil,
_boneIndex = nil,
_basePos = nil,
_baseRot = nil,
_baseScale = nil,
_t = 0.0
}
function BoneApiTest:OnStart()
self._renderer = self.owner:GetSkinnedMeshRenderer()
if not self._renderer then
Debug.LogError("[BoneApiTest] SkinnedMeshRenderer introuvable")
return
end
local boneCount = self._renderer:GetBoneCount()
Debug.LogInfo("[BoneApiTest] Bone count = " .. tostring(boneCount))
if self.logBonesOnStart then
for i = 0, boneCount - 1 do
Debug.LogInfo("[BoneApiTest] Bone[" .. i .. "] = " .. tostring(self._renderer:GetBoneName(i)))
end
end
self._boneIndex = self._renderer:GetBoneIndex(self.targetBoneName)
if not self._boneIndex then
if boneCount > 0 then
self._boneIndex = 0
Debug.LogWarning("[BoneApiTest] Bone '" .. self.targetBoneName .. "' introuvable, fallback sur l'index 0")
else
Debug.LogError("[BoneApiTest] Aucun bone disponible")
return
end
end
self._basePos = self._renderer:GetBoneLocalPosition(self._boneIndex)
self._baseRot = self._renderer:GetBoneLocalRotation(self._boneIndex)
self._baseScale = self._renderer:GetBoneLocalScale(self._boneIndex)
if not self._basePos or not self._baseRot or not self._baseScale then
Debug.LogError("[BoneApiTest] Impossible de lire le transform local du bone")
self._boneIndex = nil
end
end
function BoneApiTest:OnUpdate(deltaTime)
if not self._renderer or self._boneIndex == nil then
return
end
self._t = self._t + deltaTime * self.speed
local wave = math.sin(self._t)
local pos = Vector3.new(
self._basePos.x,
self._basePos.y + wave * self.positionAmplitude,
self._basePos.z
)
self._renderer:SetBoneLocalPosition(self._boneIndex, pos)
local scaleFactor = 1.0 + wave * self.scaleAmplitude
local scl = Vector3.new(
self._baseScale.x * scaleFactor,
self._baseScale.y * scaleFactor,
self._baseScale.z * scaleFactor
)
self._renderer:SetBoneLocalScale(self._boneIndex, scl)
local rotOffset = Quaternion.new(Vector3.new(0.0, wave * self.rotationAmplitude, 0.0))
self._renderer:SetBoneLocalRotation(self._boneIndex, self._baseRot * rotOffset)
end
function BoneApiTest:OnDestroy()
if not self._renderer or self._boneIndex == nil then
return
end
self._renderer:SetBoneLocalPosition(self._boneIndex, self._basePos)
self._renderer:SetBoneLocalRotation(self._boneIndex, self._baseRot)
self._renderer:SetBoneLocalScale(self._boneIndex, self._baseScale)
end
return BoneApiTest |
adriengivry
reviewed
Apr 15, 2026
Member
adriengivry
left a comment
There was a problem hiding this comment.
Thanks for making this PR!
Looks good to me!
The only feedback I would have is that when the character is in T-pose (no animation clip selected), it's not possible to modify bones (the new pose won't be shown).
Contributor
Author
Done ! |
adriengivry
requested changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR exposes skeleton/bone runtime controls for
SkinnedMeshRendererin Lua.What was added:
GetBoneCount()GetBoneName(index)GetBoneIndex(name)GetBoneLocalPosition(index)GetBoneLocalRotation(index)GetBoneLocalScale(index)SetBoneLocalPosition(index, position)SetBoneLocalRotation(index, rotation)SetBoneLocalScale(index, scale)Implementation details:
CSkinnedMeshRenderer.Related Issue(s)
Fixes #677
Review Guidance
SkinnedMeshRenderer.GetBoneIndex("Head")(or another bone).GetBoneLocal*.SetBoneLocal*.nil/false.Play,SetAnimation, etc.) keep working.Screenshots/GIFs
B.mp4
Checklist