Parent and un-parent an object from a character's hand

Wondering how to accomplish a certain animation task? Ask here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
Rnoir
Posts: 18
Joined: Wed Oct 12, 2016 4:07 pm
Location: Buenos Aires, Argentina

Parent and un-parent an object from a character's hand

Post by Rnoir »

There might be a simple solution to this, but I couldn't find and andswer to it yet.
I want to make characters grab objects from the background or from other characters hands. So basically I want to know how to parent that object to a character's hand at the moment the character grabs it and un-parent the object when the character drops said object or gives it to another character (meaning un-parent the object from the character's hand giving it and parenting the object to the character receiving it).

Image
User avatar
slowtiger
Posts: 6067
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany
Contact:

Re: Parent and un-parent an object from a character's hand

Post by slowtiger »

The simple solution: duplicate the object, place one on the table, include the other one into the character rig (bind it to the hand) and make it invisible. Switch visibility when needed.
AS 9.5 MacPro Quadcore 3GHz 16GB OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15

Moho 14.1 Mac Mini Plus OS 13.5
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: Parent and un-parent an object from a character's hand

Post by Víctor Paredes »

You can also animate the bone parenting. To do that, the object must be inside of the bone layer and be bound to its own non parented bone.
At the frame the character hand is close to the object, select the object's bone and then the Reparent bone tool and click over the hand bone. Now the object bone will be child of the hand.
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
User avatar
Greenlaw
Posts: 9191
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Parent and un-parent an object from a character's hand

Post by Greenlaw »

I was going to mention keyframing bone parenting but Victor beat me to it.

That said, if I was doing this, I would follow SlowTiger's suggestion. Swapping the visibility between duplicate objects is easier to set up and manage, and is less likely to mess up if you need to change your rig or animation later. (IMHO.)

But certainly try both so you can see the difference, and choose the method that works best for you.

A note to Moho developers who maybe reading this: I might feel differently if bone parent keys could use other interpolation modes and not just step mode, like key-frameable constraints found in many 3D animation programs. (Same with Bone targeting; maybe more so with targets.) :)
Rnoir
Posts: 18
Joined: Wed Oct 12, 2016 4:07 pm
Location: Buenos Aires, Argentina

Re: Parent and un-parent an object from a character's hand

Post by Rnoir »

slowtiger wrote:The simple solution: duplicate the object, place one on the table, include the other one into the character rig (bind it to the hand) and make it invisible. Switch visibility when needed.
Víctor Paredes wrote:You can also animate the bone parenting. To do that, the object must be inside of the bone layer and be bound to its own non parented bone.
At the frame the character hand is close to the object, select the object's bone and then the Reparent bone tool and click over the hand bone. Now the object bone will be child of the hand.
Ok, both methods seems to work. Thanks for the tips!
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Parent and un-parent an object from a character's hand

Post by hayasidist »

Greenlaw wrote:A note to Moho developers who maybe reading this: I might feel differently if bone parent keys could use other interpolation modes and not just step mode, like key-frameable constraints found in many 3D animation programs. (Same with Bone targeting; maybe more so with targets.) :)
hear hear!! and wouldn't it be nice if a bone could have a target in a different group...
User avatar
slowtiger
Posts: 6067
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany
Contact:

Re: Parent and un-parent an object from a character's hand

Post by slowtiger »

I wonder if that's possible at all, since I believe Moho still calculates and renders one layer after another (thus its mask construction) and "forgets" it after that. Targetting something in a different layer hierarchy would need some temporal memory for something which might have been rendered or will be rendered at a different point in time.
AS 9.5 MacPro Quadcore 3GHz 16GB OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15

Moho 14.1 Mac Mini Plus OS 13.5
User avatar
Greenlaw
Posts: 9191
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Parent and un-parent an object from a character's hand

Post by Greenlaw »

hayasidist wrote:hear hear!! and wouldn't it be nice if a bone could have a target in a different group...
I would love that. I often wish we had a 'global' bone layer at the top, where I can add bones that any sub-level bones could be targeted or parented to.

For example, when I need to animate two characters holding hands. Currently, I must either put all the character art and bones under the same bone group, or carefully matchmove the independent arms rigs frame by frame, or make a target bone for each rig and then copy/paste the keys from one target to the other whenever I change the animation. (The latter is my preferred method but it's still a little clunky.)

It would be much easier if I could add a shared 'hand' target bone in a master bone layer, and then target both characters' forearm bones to it from their individual bone layers.
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Parent and un-parent an object from a character's hand

Post by hayasidist »

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)
Post Reply