PDA

View Full Version : how can I know if an object has moved?


kill Whale
03-23-2003, 05:20 AM
I want use a expression to get data of a object's movement at current frame----to know if the object has been moved. someone could help me?:airguitar

bigfatMELon
03-23-2003, 05:48 AM
compare its position at the current frame to its position at the previous frame.

-jl

kill Whale
03-23-2003, 08:40 AM
Thanks:)but,there is still a problem----how to get the object's position at the previous frame?in another words,how to keep the previous position to compare with the current position?

kill Whale
03-23-2003, 05:27 PM
I've got it.
float $position=objectname.translateX;
float $oldposition;
if($position>$oldpostion){
statement;
}
float $oldposition=objectname.translateX;

alex.ongaro
03-23-2003, 10:10 PM
You can query the value at previous frame like this:

float $oldXpos = `getAttr -t (frame -1) objectName.tx`;

Or to speed up maya you could also create a frameCache node.

-alexongaro

kill Whale
03-24-2003, 06:30 AM
thank u Alex,I will try it.

mark_wilkins
03-26-2003, 04:14 AM
Unfortunately, a getAttr like that won't really tell you whether something has moved if it's moving as a result of a parent's motion.

The xform command can be used with the -ws option to give you an object's position in world space, and you can stuff the result into a global variable on a frame-by-frame basis. You may also be able to do a getAttr -t on the world space matrix and compare the elements to see whether the object has moved.

-- Mark

kill Whale
03-26-2003, 05:46 AM
thank u mark,you made me knew more about it.

CGTalk Moderation
01-14-2006, 06:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.