Home Technical Talk

Snap rotation Maya..

polycounter lvl 9
Offline / Send Message
Flynny polycounter lvl 9
Hey guys sorry to post such a simple (i hope) question here but does anyone know of a way to snap an object to another object in maya that also snaps the rotation?

Long story short I cant apply a constraint as im animating a hand thats jumping between alot of stuff (grab here an there etc) and ive also animated at other points in the timeline between other various parents so adding another constrain would sort of skew things up.

Up till now ive been gettin over this problem by just animating on perframe and doing it by eye, but surely theres a better way?

Or is Maya 8.5 just that crap?

Replies

  • ivars
    Offline / Send Message
    ivars polycounter lvl 17
    It's hard to say without knowing your animation setup / rig. Could you maybe share some screens?
  • MoP
  • Funky Bunnies
    Offline / Send Message
    Funky Bunnies polycounter lvl 17
    i think I've tried that one and I couldn't get it to behave correctly sometimes because of the way it looks up rotation. Give that shot first, though.

    if not, I tested my quick script on constrained hierarchical things with animation
    I didn't add a gui though, so it just fully aligns to rotation and position. So hopefully it would work in this situation.


    {
    //snaps to last selected object

    //store selected transforms
    string $selection[] = `ls -sl -l -tr`;
    if (`size $selection`>1)
    {
    warning ( (`size $selection`-1) + " objects snapped to last selected object");

    int $lastIndex = (`size $selection`-1);

    //create a locator to parent constrain
    string $pivLocator[] = `spaceLocator -p 0 0 0 -n pivLocator`;
    string $constraintTemp[] = `parentConstraint -weight 1 $selection[$lastIndex] $pivLocator[0]`;
    float $initPos[] = `xform -q -ws -rp $pivLocator[0]`;
    float $initRot[] = `xform -q -a -ro $pivLocator[0]`;

    delete -constraints $constraintTemp[0];
    delete $pivLocator;

    //reapply selection of just the things I care about
    select -r $selection;
    select -d $selection[$lastIndex];

    //move them foos
    move -a -ws -xyz $initPos[0] $initPos[1] $initPos[2];
    //rotate them foos
    rotate -a -ws -xyz $initRot[0] $initRot[1] $initRot[2];

    }
    else
    error "select two or more objects first!";

    }


    [edit: did a quick edit to check if you have enough objects selected, oops!]
  • Flynny
    Offline / Send Message
    Flynny polycounter lvl 9
    Thankyou so much guys! Wasnt expecting such a speedy response!
    Ivars, unfortunately i cant show squat ;) and im too lazy to rip apart the scene to show ;)

    Mop havent tried your idea but it looks like a good answer.
    But Funky Bunnies saves the day, i OWE YOU BIG TIME!
Sign In or Register to comment.