Jump to content

Ray cast help


ItHadToComeToThis
 Share

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

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

Recommended Posts

I need some help in detecting a prim with a script inside using a raycast. I am a tad confused as to why this isnt working

rCast=llCastRay(llGetPos(),llGetPos()+<2.5,0.0,0.0>*llGetCameraRot(),[RC_REJECT_TYPES,RC_REJECT_LAND,RC_DETECT_PHANTOM,TRUE,RC_DATA_FLAGS,RC_GET_ROOT_KEY,RC_MAX_HITS,1]);

The only thing i want it to reject is hitting land. Any other kind of object i need it to detect. I have no other reject flags except land. Can anyone point out what i missed here.

 

Link to comment
Share on other sites

2 hours ago, Wulfie Reanimator said:

Yeah, why isn't it?

Are you getting errors? Are you not hitting objects? What's happening and how is it different from what should be happening?

 

50 minutes ago, Qie Niangao said:

Not sure why you're not getting some result, but if you're doing what I think you're doing, you may eventually want to cast from llGetCameraPos() in the direction of llRot2Fwd() of llGetCameraRot(). I have a sample in a box somewhere around http://maps.secondlife.com/secondlife/Bay City - Dennis/133/230/26 if it helps to take a look.

Well, as it turns out I discovered it was working there was just something wrong with my ray cast which might well be what Qie is describing above. The object it wasn't hitting would return a value but only when I aimed at the top left corner of the object. I am going to play around with it later on when I log back into SL and try what Qie has suggested.

I had a box rezzed in the air in front of me and I can aim at most of it all day long and it returns no results, but aim at the top left and I get a hit. So, I would use llGetCameraPos()+<2.0,0.0,0.0>*llRot2Fwd(llGetCameraRot())?

Further question on topic but not on this part of it. Is it possible to curve a single ray so it sweeps an area or would that just involve me casting multiple rays across those directions?

Edited by ItHadToComeToThis
Link to comment
Share on other sites

It may be helpful to have a debug routine where you rez a marker prim at the coordinates the ray impacts, and perhaps also at the calculated endpoint you fed into the llCastRay function.

As for sweeping a single ray, that is not possible. The llCastRay function will fire a single ray between the start and end positions and it is practically instantaneous. You would need to set up and fire multiple rays in a sweeping pattern to cover any area other than a straight line.

  • Like 1
Link to comment
Share on other sites

3 hours ago, Qie Niangao said:

in the direction of llRot2Fwd() of llGetCameraRot()

2 hours ago, ItHadToComeToThis said:

So, I would use llGetCameraPos()+<2.0,0.0,0.0>*llRot2Fwd(llGetCameraRot())?

  • "llRot2Fwd(rotation)" returns the local X axis of that rotation.
  • It can be simplified to "<1,0,0> * rotation"
  • And since the ray needs to be 2 meters long instead of 1 meter, it can be changed to "<2,0,0> * rotation"

This is pointed out even on the wiki page of the function.

  • Like 1
Link to comment
Share on other sites

11 hours ago, Wulfie Reanimator said:
  • "llRot2Fwd(rotation)" returns the local X axis of that rotation.
  • It can be simplified to "<1,0,0> * rotation"
  • And since the ray needs to be 2 meters long instead of 1 meter, it can be changed to "<2,0,0> * rotation"

This is pointed out even on the wiki page of the function.

Okay so. I have fixed it and now i'm facing another issue. I need the ray to not detect myself while i'm running and firing it. I have tried starting the ray from all kinds of different places up to 1m in front of me and it still detects me if i am running forward. Annoyingly i could do with it firing from the camera position in mouse look for up close combat so 1m away isn't ideal.

I have thought about putting in a filter that tells it to ignore any casts that are not the caster but is there a way to get the ray to just flat out ignore the caster in the  same way the RC_REJECT flags work?. I cant see anything on the wiki

Link to comment
Share on other sites

30 minutes ago, ItHadToComeToThis said:

Okay so. I have fixed it and now i'm facing another issue. I need the ray to not detect myself while i'm running and firing it. I have tried starting the ray from all kinds of different places up to 1m in front of me and it still detects me if i am running forward. Annoyingly i could do with it firing from the camera position in mouse look for up close combat so 1m away isn't ideal.

I have thought about putting in a filter that tells it to ignore any casts that are not the caster but is there a way to get the ray to just flat out ignore the caster in the  same way the RC_REJECT flags work?. I cant see anything on the wiki

Welcome to Classic SL Combat Problems #9752.

No, you can't outright reject the caster/owner. The typical solution is to start from some distance in front of the avatar, possibly while accounting for velocity.

Another solution is to change RC_MAX_HITS to 2 and explicitly ignore the first hit if it's the owner.

Edited by Wulfie Reanimator
Link to comment
Share on other sites

You mentioned earlier that you want to do a sweeping pattern, which would require multiple rays... assuming that's still the case, are you updating the start position for each new ray? If not, that might be why you keep hitting yourself as you move forward. The origin might be correctly positioned ahead of your avatar for the first ray, but by the time you cast the next one, your avatar may have moved into range.

Are you casting all the rays in the sweep at once and then processing them afterwards, or are you processing each one as they are cast? That could be the difference.

Edited by Fenix Eldritch
Link to comment
Share on other sites

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