|
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
|
09-19-2008 10:17
heyas;
im doing a velocity check on the avatar by doing llvecmag on the... whats velocity, llgetvelocity? now, as i understand, the velocity gives me how fast the avatar is moving in all 3 directions, and llvecmag just dispenses with all that and gives me the absolute speed regardless of directionals.
that's good, but now i need to tell the difference between the avatar going forward, and the avatar going backward. can i get this from the velocity x bits if i'm using an attachment on an avatar? or is this world x?
_____________________
Why Johnny Can't Rotate: http://forums.secondlife.com/showthread.php?t=94705
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
09-19-2008 10:25
llGetVel() returns the velocity in region coordinates, not relative to the avatar. You'll have to transform it to to the avatar's coordinate frame. There's an explanation and example in: http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetVelAlternately you could find the (unit) vector in region coordinates that points along the avatar's forward direction, compute a dot product, and use the sign of the result: vector velocity = llGetVel(); vector fwd = llRot2Fwd(llGetRot());
float fwdVelocityComponent = velocity*fwd; // Dot product
if (fwdVelocityComponent > 0.0) { // Going forward } else if (fwdVelocityComponent < 0.0) { // Going backward } else { // Going neither forward nor backward; maybe sideways/up/down, maybe still }
http://en.wikipedia.org/wiki/Dot_product
|
|
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
|
09-25-2008 09:54
great!
thanks again, hewee :)
|