A way to use "UpdateCurFrame" in a "LayerScript" function ?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
bbrraayyaann
Posts: 69
Joined: Thu Jan 24, 2019 3:52 am

A way to use "UpdateCurFrame" in a "LayerScript" function ?

Post by bbrraayyaann »

I am trying to use "UpdateCurFrame" to update the properties of a bone as follows but it is not working, is there a way to use it or is there another way to update the properties in a "LayerScript"? I also tried "UpdateBoneMatrix" but it doesn't work either.

Code: Select all

function ProcessBonePair(skel, ik, b, layerFrame)
    local boneik = skel:BoneByName(ik)
    local bone = skel:BoneByName(b)
    if bone and boneik then
        if bone.fTargetBone.value == -1 then
            boneik.fIgnoredByIK = true
        else   
            local parent = skel:Bone(bone.fParent)
            local animScaleValue = bone.fAnimScale:GetValue(layerFrame)
            if animScaleValue > 0.5 then
                boneik.fIgnoredByIK = true
                bone.fMaxAutoScaling = 1
                parent.fMaxAutoScaling = 1
            else
                boneik.fIgnoredByIK = false
                bone.fMaxAutoScaling = 100
                parent.fMaxAutoScaling = 100
            end
        end
    end
end
function LayerScript(moho)
    local skel = moho:Skeleton()
    if not skel then return end
    local layerFrame = moho.layerFrame
    ProcessBonePair(skel, "IKLeftArm", "LeftForeArm", layerFrame)
    ProcessBonePair(skel, "IKRightArm", "RightForeArm", layerFrame)
    ProcessBonePair(skel, "IKLeftLeg", "LeftLeg", layerFrame)
    ProcessBonePair(skel, "IKRightLeg", "RightLeg", layerFrame)
    moho.layer:UpdateCurFrame()
end
Post Reply