Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   Maya Expression - Value of Object Attribute at specific frame (https://simplymaya.com/forum/showthread.php?t=33572)

Ecker00 10-01-2010 02:21 PM

Maya Expression - Value of Object Attribute at specific frame
 
Hi!
To get the value of an objects attribute at the CURRENT time is just to write:

ObjectName.AttributeName

But what if I want to get the value of the objects attribute at a SPECIFIC time?
Would be grateful for a fast reply, cheers!

NextDesign 10-01-2010 06:46 PM

Nasty little hack-together:

// set below
//===================
$object = "polySphere1";
$attribute = "radius";
$getAtTime = 24;

// don't touch below
//===================
$oldTime = `currentTime -q`;

currentTime $getAtTime;

$value = `getAttr ($object + "." + $attribute)`;

currentTime $oldTime;

// do something with the result
print $value;

Ecker00 10-01-2010 09:40 PM

THANK YOU SO MUCH! :D
That was exactly what i needed! Was going nuts because I couldn't find a way to do that. I was sure it was an easier way to do it, but this method works great!

Basically now I've made a script with make my characters feet move correctly according to the ground. So I animate him to walk on the spot, and the scripts moves him correctly on the ground according to the movement of his feet.

I'm very new to Maya, and this is my first real project (making a dance), and this will make my life a lot easier!

:beer:
Cheers man!

NextDesign 11-01-2010 02:47 AM

No problem mate. Glad to help out.

bendingiscool 11-01-2010 08:42 AM

Hey there,

As you are new to all this it's probably not so important, but if you want to get realistic motion, you are going to have to think about getting the feet not to slide along the floor.

Unless you have already accounted for that in some way?

cheers,
Chris

Ecker00 11-01-2010 06:25 PM

@ bendingiscool
Hi, that is the basic idea behind the script. As I had problems with the characters feet sliding on the ground. So the script calulates how the character would move around according to the animation of the feet. If that makes sense... or just look at this crap example I put together in 5 min: LINK

NextDesign 11-01-2010 07:40 PM

You usually always want to animate the center of gravity by hand, as this is where a lot of the illusion of weight comes from.

In your case, you need to animate the root translation node, as well as the center of gravity to create a good look.

You application of the script looks cool though! You just need to find a way to be able to create some animation on top of the generated animation. Perhaps by having a locator, parented to another. The script run on the child, and you animation the parent. You then parent constrain the child locator to the center of gravity.

See if that works.

Ecker00 11-01-2010 07:58 PM

Thanks for the tips NextDesign!
I really see what you mean, and I've been thinking about it. Because it's hard to make it look natural doing animation with math. It's smart to have manual controle over everything so the script don't overrun natural motion. I'll try the method you mentioned, was a good idea.

Thanks once again! =)


All times are GMT. The time now is 09:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018