View Full Version : how can I know if an object has moved?
03 March 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
03 March 2003, 05:48 AM
compare its position at the current frame to its position at the previous frame.
03 March 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?
03 March 2003, 05:27 PM
I've got it.
03 March 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.
03 March 2003, 06:30 AM
thank u Alex,I will try it.
03 March 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.
03 March 2003, 05:46 AM
thank u mark,you made me knew more about it.
01 January 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.