Jump to content

Getting cast ray to ignore mouse rotation


ItHadToComeToThis
 Share

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

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

Recommended Posts

I am having an issue with this cast ray in that when I go into mouse look the ray starts firing from the direction I am looking. How do I make this ignore mouse look and only focus in the forward direction that the avatar is facing?.

rCast=llCastRay(llGetPos(),llGetPos()+<2.0,0.0,0.5>*llGetRot(),[RC_REJECT_TYPES,RC_REJECT_AGENTS|RC_REJECT_LAND,RC_DETECT_PHANTOM,FALSE,RC_DATA_FLAGS,RC_GET_ROOT_KEY,RC_MAX_HITS,1]);

Link to comment
Share on other sites

Welcome to the world of quirks. llGetRot returns the camera's exact rotation in mouselook, otherwise an approximate rotation of the avatar. (Unless the avatar is sitting.)

Simplest solution I can think of is to just "flatten" the vector.

vector avatar = llGetPos();
vector end = <2,0,0.5> * llGetRot();
end.z = avatar.z;

Now the ray should always fire along a horizontal plane, no matter which way you're looking.

You might want to normalize and re-scale the vector (and add the 0.5 meter elevation back), otherwise the ray will be really short if you look straight up/down.

Edited by Wulfie Reanimator
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1401 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...