|
Jessica Margetts
Registered User
Join date: 23 Jan 2006
Posts: 18
|
05-04-2008 23:08
I need to be able to simulate throwing a small object. As such, I have some questions about rezzing the "thrown" object.
How does the velocity work?
What would be the best method for making sure it threw the object the direction the avatar is facing, and attempting to control the distance?
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-05-2008 00:21
The direction an avatar wearing the attachment is facing can be found with 'llRot2Fwd(llGetRot())'. Note that this may point up or down if the avatar is in mouselook. If you want to always base the trajectory on the horizontal component of this direction, you might instead want to do it like this: vector getFacing() { rotation rot = llGetRot(); vector dir = llRot2Fwd(rot); if (1.0-llFabs(dir.z) < 0.01) // Looking straight up/down; "pitch" to horizontal { if (dir.z > 0.0) { dir = -llRot2Up(rot); } else { dir = llRot2Up(rot); } } else { dir.z = 0.0; dir = llVecNorm(dir); } return dir; }
As for velocity and range, you might want to take a look at http://en.wikipedia.org/wiki/Trajectory (note that--and I believe this is still true for Havok 4--there's no drag in SL and wind has no physical effect on objects and avatars).
|