Jump to content

Trying to Get Raycast from Child Prims Angle


BrownBoxStudio
 Share

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

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

Recommended Posts

SOLVED EDIT: Sorry, always asking these questions too soon. I forgot to add the child prims rotation to the root prims rotation. I'll leave this here incase anyone wants to ever do the same thing. The working code is as such. It allows you to have a raycast from a child prim, at any rotation, while the room prim is also at any rotation. 

    vector ray_start = llGetPos() + ((childprim_pos + < 0, 0, .05>) * llGetRot());
    vector ray_end = ray_start + (< 0, 2.5, .05>*(childprim_rot*llGetRot()));

    list results = llCastRay(ray_start, ray_end,[RC_REJECT_TYPES,RC_REJECT_PHYSICAL,RC_DETECT_PHANTOM,TRUE,RC_MAX_HITS,1]);

_____________________________________________________________

I am trying to create a raycast that starts at a child prim and goes X meters in a direction relative to the child prims rotation relative to the root rotation. The child prim is an aiming device for a game and can be rotated by controls so I need the raycast to stay in the same orientation relative to the child prims position and rotation. I thought I knew how to do this but so far it has not worked. Basically I am rotating a vector around a child prims position around a root prims rotation. I think the child prim aspect is messing me up. 

 

This is my current code; arrow_pos and arrow_rot are the child prims params.

 

    vector ray_start = llGetPos() + ((arrow_pos + < 0, 0, .05>) * llGetRot()); //arrows adjusted position based on root rotation.
    vector ray_end = (ray_start) * llGetRot())+(< 0, 2.5, .05>*arrow_rot);

    list results = llCastRay(ray_start, ray_end,[RC_REJECT_TYPES,RC_REJECT_PHYSICAL,RC_DETECT_PHANTOM,TRUE,RC_MAX_HITS,1]);

 

 

To get a child prims global position, ray_start, I thought you adjust the child prim position by the root rotation and then add that new position to the root position. Then to get the ray_end I took the new vector, modified that by the child prims rotation and added that to the child prims position. So far this has not worked. Any suggestions of where I have gone wrong would help.

 

I am finding this extra hard because I cant think of a way to visual the ray casting. I have no way to see how off I am. Is there an easy way to see the ray that is cast? 

Link to comment
Share on other sites

It's a vector offset from the child prim's position, Steph.  The start position for the cast ray is calculated from the root position, offset to the child prim's position plus another <0.0,0.0,0.05> and then corrected for the rotation of the root.  The end position is the same, plus an offset of <0.0,2.5,0.05> that is corrected for both the root rotation and the rotation of the child prim.

Link to comment
Share on other sites

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