Sunday, 2 May 2010

Simple Picking Up and Object in Maya Tutorial

Real Easy Pick-up-Object Tutorial for Maya  EDIT: Please see following post for shorter version

http://ldunham.blogspot.com/2010/05/shortened-version.html


This tutorial is now scripted.
Get the script here - Download



Simple Tutorial i've picked up to solve alot of problems with getting a character to pick up an object and to put it down again or throwing etc. Its almost exactly the same as the original found at www.jonathanrnelson.com

1. Create 3 locators equally spaced apart and name (left to right);

Hand

Object

Prone

The locator name siginifies what role the locator will have.



2. Add a new attribute to the 'Hand' locator (select the 'Hand' Locator, in the channel panel click 'Edit' - 'Add Attribute')

Name the new attribute 'Grasp' and select 'Float' and 'Scalar', 'minimum' as 0, 'maximum' as 10, and leave 'default' blank (you actually have two options for creating the 'Grasp', this one creates a blended attribute so you can blend the object between the hand and prone position which is recommended but if you want an 'Off' and 'On' function, instead of selecting 'Float' choose 'Boolean' and no need to enter maximum or minimum values).

(or if you want to be a smart-arse about it select 'Enum', click on 'Green' under 'Enum Names' and rename 'Prone' and rename 'Blue' to 'Hand').

Then click ok.


3. You want the object to be receive its 'position and rotational information from the two other locators by way of constraints', basically shift-select 'Hand', 'Prone' and then 'Object' in that order. The press F2 to select the Animation Toolset and under 'Constrain' click 'Point' - 'Options' - 'Edit' - 'Reset Settings' then 'Add' then immediately do the same for 'Orient'.

Both constraints from both 'Hand' and 'Prone' Locators are fully influencing the 'Object' locator now, well need to be able to control the influence with the 'Grasp' attribute we made using 'Driven Keys'.


4. Select 'Hand' locator and press F2 again (need to be on the Animation Toolset) and select 'Animate', 'Set Driven Key', 'Set'. A new window pops up, and with the 'Hand' locator still selected click 'Load Driver'. 'Hand' then appears in the top section along with its attributes, we'll use this to blend between the locators, so then open the 'Outliner' under 'Window' and expand the 'Object' locator and select both the 'Point' and 'Orient' constraints that appear.

Then with them both selected on the 'Set Driven Key' window click 'Load Driven'. So the 'Hand' locator and its attributes should be in the top section (Driver) and the 'Point Constraint' and 'Orient Constraint' should be in the bottom (Driven). You need to decide the value structure will be for the 'Grasp' Attribute, but ideally when 'Grasp' = 0 the object will not be held and will be controlled by the 'Prone' locator and when its 10 it will be controlled by the 'Hand' locator.
Click on the 'Grasp' Attribute in the 'Set Driven Key' Window and make sure that the attribute is 0 (or 'Off' or 'Prone').
Then select the 'Object_pointConstraint1' and then select both 'Hand W0' and 'Prone W1'.





Click on the 'Object_pointConstraint1' to select the object and in the channel editor on the right change the values of 'Hand W0' to 0 and 'Prone W1' to 1.
In the 'Set Driven Key' window, click 'Key'.

Repeat for 'Object_orientConstraint1'.

Dont close the Driven key window.

5. We've told 'Object' locator to be controlled and to be in the place of the 'Prone' locator now, and so we need to do the same for the 'Hand' locator.

So, select the 'Hand' locator and set 'Grasp' to 10 and in the 'Set Driven Key Window' select 'Object_pointConstraint1' again and then 'Hand W0' and 'Prone W1' and in channel editor change values of 'Hand W0' to 1 and 'Prone W1' to 0.

Click 'Key' and repeat for 'Object_orientConstraint1' again.

If everything went as it should then when you scroll the value of the 'Grasp' attribute on the 'Hand' locator, you should see the 'Object' locator blend between the two.



6. You can now put this into your scene to use to pick up a cup or throw a ball. Just parent the 'Hand' locator to you characters hand or whatever, parent the 'Prone' locator to wherever you wan the object to start from and then on the object you want to pick up/etc, select it, press 'Ctrl' + 'g' to group and parent that group to the 'Object' locator (we group it because parenting causes the object to inherit its parents vales, which can cause problems so easier to avoid that by parenting a group instead).

Personally, when animating a character, instead of animating the locator 'Grasp' attribute which involves finding and selecting the locator, its easier to select my characters hand controller, add a new attribute called 'Grasp' (and has exactly the same values as the original 'Grasp' attribute) and setting driven keys for the new 'Grasp' attribute on the characters controller to control the 'Grasp' attribute on the locator.



Hope this helps, I know its a bit lengthy and if you know what your doing it could be cut down to a couple of sentences but its supposed to be in-depth.

Anyways, have fun you crazy kids.