View Full Version : speed ???

 ynedelin10 October 2003, 09:44 PMhow can I get the speed of an animated object? so i could use it to change the color of that object. for instance if it moves fast it becomes red and if it slows down it becomes black ??? thanks yury
misterdi
10 October 2003, 06:45 AM
You can query object position one frame before and one frame after. Distance between this two value divided by 2 will give you approximately avg speed at current frame.

Or you can also calculate speed in and speed out of a frame and average it.

if you are using getAttr, you could specify time to it.

Put this calculation as an expression to a dynamic attribute of transform will give you extra information on speed which could drive the color.

mark_wilkins
10 October 2003, 04:51 PM
Be careful -- using getAttr to get an attribute at a different time value can cause recalculation of large parts of the scene if what you're examining is constrained, for example, to something complicated.

-- Mark

Firas
11 November 2003, 09:28 AM
the speed of pCube1 :
just add attr call it "speed" .. and paste this expression on it.

float \$lastPosX = `getAttr -t (frame-1) pCube1.tx`;
float \$lastPosY = `getAttr -t (frame-1) pCube1.ty`;
float \$lastPosZ = `getAttr -t (frame-1) pCube1.tz`;

pCube1.speed = abs (mag (<<pCube1.translateX,pCube1.translateY,pCube1.translateZ>>)
- mag (<<\$lastPosX,\$lastPosY,\$lastPosZ>>) );

now u can conect "speed" to anything.

artist3dChicago
11 November 2003, 03:54 PM
thanks thats awesome

mark_wilkins
11 November 2003, 06:58 PM
note that if you use getAttrs in expressions like that, the expression won't update until you move the timeline. (assuming you're changing the cube's animation.)

-- Mark

mental
11 November 2003, 09:03 PM
also if you're interested here is a tutorial on putting together a unidimensional speed script.

Swanimator's Unidimensional Speed Script (http://www.swanimator.com/tipstutorials/Give%20Speed%201%20Dimension%20(Z)/2002.10.17%20-%20Uni-Dimensional%20Speed%20Script.htm)

-mental :surprised

alexx
11 November 2003, 11:31 AM
if you are somewhat lazy, you can group a passive rigid body under your animated object.
that one holds a "speed" attribute already which you can just read

cheers

alexx

CGTalk Moderation
01 January 2006, 12: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.

1