Setting polar velocity--need speed component
by Jason McIntosh · in Torque Game Builder · 03/01/2005 (4:27 pm) · 4 replies
I'm setting an object's polar velocity to bounce it at a controlled range of angles. Once I have the angle, I want to call setLinearVelocityPolar( angle, speed ) but I also need the speed part.
How can I get the current speed? Do I need to calculate the vector magnitude (speed) "by hand"?
My math is very rusty. :)
How can I get the current speed? Do I need to calculate the vector magnitude (speed) "by hand"?
My math is very rusty. :)
About the author
#2
Hope this helps.
- Melv.
03/02/2005 (3:08 am)
@Jason: If you wanted to adjust the angle the object was moving but maintain its current speed, use the vector utility helper functions (see ref-doc) like so:-%obj.setLinearVelocityPolar( myAngle, vectorLength2D( %obj.getLinearVelocity() ) );
Hope this helps.
- Melv.
#3
03/02/2005 (5:07 am)
Melv, that's exactly what I needed! Thanks!!
#4
- Melv.
03/02/2005 (5:21 am)
No problem. Vector utility functions are your friends. More of those to come.- Melv.
Torque Owner Pete111