View Full Version : speed ???
10-24-2003, 10:44 PM
how 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 ???
10-25-2003, 07: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.
10-25-2003, 05: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.
11-02-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.
11-02-2003, 03:54 PM
thanks thats awesome
11-02-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.)
11-02-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)
11-03-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
01-16-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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.