Position control for nested bones and display-time scripting

General Moho topics.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
dfreynolds
Posts: 3
Joined: Mon Mar 14, 2016 10:58 pm

Position control for nested bones and display-time scripting

Post by dfreynolds »

I'm creating a character rig and making use of the reference features in Moho.

For my character I've created most of the bones and art under my CharacterBone layer. I've then created an ArmPrime layer that I've built my arm bones and art. I've got the arm's smart bones and actions all working, and the IK working with a target controller bone.

Now I've hidden the ArmPrime layer and created two reference layers and flipped one of them. The unflipped reference arm is my right arm and the flipped reference arm one is my left arm: ArmRefRight and ArmRefLeft

This is all parented under my CharacterBone layer, on top of the rest of my art.

This works surprisingly well. I can select the CharaterBone layer and see all the bones except the arm bones. I can select either the left or right arm reference layers and see my arm bones and the controller bone. The reference layers are children of the left and right shoulder bones in the CharacterBone layer.

Now my question is this. Is there any way to create a pair of IK target bones in the CharacterBone layer and have their positions control the positions of the IK targets in the reference layers?

I can't seem to be able to do this. When I select one of the IK target bones in a reference layer and try to do a position bone constraint I can only select bones in my ArmPrime layer.

Failing a built in constraint, is there anything in Moho that works like expressions in After Effects? I've built controllers like this using javascript expressions in AE that map IK targets (all using DUIK) into the world space for high level controllers.

I can see that there is scripting in Moho, using Lua, but is there any scripting that gets evaluated each time a frame is loaded or modified?

Most of the scripting examples I see in Moho seem to be concerned with manipulating the Moho document object model rather than display-time evaluation.
User avatar
hayasidist
Posts: 3854
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Position control for nested bones and display-time scrip

Post by hayasidist »

dfreynolds wrote:I can see that there is scripting in Moho, using Lua, but is there any scripting that gets evaluated each time a frame is loaded or modified?
yes - Layer scripts.
on the layer settings General tab there's an "embedded script file" checkbox.

Code: Select all


function LayerScript(moho)
	local vec = LM.Vector2:new_local()
	if moho.frame == 0 then
		return true
	end
	local mesh = moho:Mesh()
	local Pt = mesh:Point(0)
	vec.x = moho.frame/50
	vec.y = -moho.frame/30
	Pt.fPos.x = vec.x
	Pt.fPos.y = vec.y
end

that trivial example script moves a point to a position that is a function of the frame number.
dfreynolds
Posts: 3
Joined: Mon Mar 14, 2016 10:58 pm

Re: Position control for nested bones and display-time scrip

Post by dfreynolds »

@ hayasidist, thanks! I'll look into layer scripting.
Post Reply