Biran Gould Posted March 3, 2022 Share Posted March 3, 2022 Hello, i was wondering, So if i know where i am using llGetRootPosition() and i know which direction i am facing using llGetRootRotation() and i want to rez an object, directly 3m in front of me, how can i work out the vector position? surely this must have been done before? Thanks 1 Link to comment Share on other sites More sharing options...
Jenna Huntsman Posted March 3, 2022 Share Posted March 3, 2022 11 minutes ago, Biran Gould said: Hello, i was wondering, So if i know where i am using llGetRootPosition() and i know which direction i am facing using llGetRootRotation() and i want to rez an object, directly 3m in front of me, how can i work out the vector position? surely this must have been done before? Thanks I posted this function on another thread somewhere, but this should do the trick: //Spherical raycasting position algorithm. Credit: Jenna Huntsman. vector SpherePos(float radial,vector rootPos,vector targetPos) //Radial offset in meters, rootPos is sphere center, targetPos is where to fire. { //vector v_rootPos = rootPos; //Info about the root prim rotation r_rootRot = llRotBetween(<1,0,0>,llVecNorm(<targetPos.x - rootPos.x,targetPos.y - rootPos.y,targetPos.z - rootPos.z>)); vector finPos = rootPos + (<radial,0,0>*r_rootRot); //radial*rootRot to get the correct offset relative to the root (accounting for rotation) then add the region coords. return finPos; } That will return the vector that's x distance from the root, in direction y (note that this is a non-normalized vector, so to get a direction you could use: llRot2Fwd(llGetRot())+llGetPos() 1 Link to comment Share on other sites More sharing options...
Mollymews Posted March 3, 2022 Share Posted March 3, 2022 43 minutes ago, Biran Gould said: i want to rez an object, directly 3m in front of me, the example code for llRezObject shows how to do this. https://wiki.secondlife.com/wiki/LlRezObject 1 Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted March 4, 2022 Share Posted March 4, 2022 (edited) The positive X axis points forward, conventionally. Z points up and Y points left. <3, 0, 0> would then mean "3 meters forward." These conventions don't have to always apply, depending on context, but those are the default assumptions you should keep in your head. Edited March 4, 2022 by Wulfie Reanimator 1 Link to comment Share on other sites More sharing options...
Biran Gould Posted March 4, 2022 Author Share Posted March 4, 2022 Thats great, thanks for your help everyone! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now