Jump to content

whats the vector infront of me?


Biran Gould
 Share

You are about to reply to a thread that has been inactive for 942 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

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

  • Like 1
Link to comment
Share on other sites

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()

  • Thanks 1
Link to comment
Share on other sites

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 by Wulfie Reanimator
  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 942 days.

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
 Share

×
×
  • Create New...