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

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

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

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

Postby Rnoir » Sun Aug 20, 2017 7:45 am

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
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

Postby slowtiger » Sun Aug 20, 2017 8:29 am

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 RAM OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB RAM OS 10.11 Quicktime 10.7.3
User avatar
slowtiger
 
Posts: 5336
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany

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

Postby Víctor Paredes » Sun Aug 20, 2017 1:09 pm

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.
Víctor Paredes
Former Moho Product Manager
Animator in Cartoon Saloon
My Youtube Channel - My webinars
User avatar
Víctor Paredes
 
Posts: 4842
Joined: Wed Jan 26, 2005 12:18 am
Location: Ireland

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

Postby Greenlaw » Sun Aug 20, 2017 6:16 pm

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.) :)
User avatar
Greenlaw
 
Posts: 4212
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles

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

Postby Rnoir » Sun Aug 20, 2017 10:27 pm

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
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

Postby hayasidist » Mon Aug 21, 2017 11:08 am

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
hayasidist
 
Posts: 2095
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

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

Postby slowtiger » Mon Aug 21, 2017 12:14 pm

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 RAM OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB RAM OS 10.11 Quicktime 10.7.3
User avatar
slowtiger
 
Posts: 5336
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany

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

Postby Greenlaw » Mon Aug 21, 2017 3:47 pm

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
Greenlaw
 
Posts: 4212
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles

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

Postby hayasidist » Mon Aug 21, 2017 5:27 pm

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)
User avatar
hayasidist
 
Posts: 2095
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England


Return to How Do I...?

Who is online

Users browsing this forum: No registered users and 4 guests