slowtiger wrote:I wonder if that's possible at all ...
it's straightforward with a layer script and hard coded bone names:
Code: Select all
function LayerScript(moho)
local vec = LM.Vector2:new_local()
if moho.frame == 0 then
return true
end
local doc = moho.document
local control = doc:LayerByName("control")
control = moho:LayerAsBone(control)
local controlSkel = control:Skeleton()
local controlBone = controlSkel:BoneByName("bone")
local skel = moho:Skeleton()
if not skel then
return false
end
local vec = LM.Vector2:new_local()
vec:Set(controlBone.fPos)
local controlledBone = skel:BoneByName("target")
local id = skel:BoneID(controlledBone)
skel:IKAngleSolver(id, vec)
end
try it with a moho doc that has:
bone layer 1: has a bone in it called "target" (at the end of a bone chain) and it's this layer that gets the embedded script.
bone layer 2: is called "control" and has a bone in it called "bone" -- to keep things simple (re calculating position) for this script I've assumed "bone" is un-parented - this bone dances around ...
.. and the "target" follows it.
(and, yes, I could have cut down the number of lines of code by cutting out unnecessary intermediate local variables but this was a proof of concept thrown together in 30 mins or so)