Jump to content

setting up llCastRay filters to detect Avatar only


Xander Lopez
 Share

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

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

Recommended Posts

I am creating a simple weapon with llCastRay, I have the following following filters set for llCastRay:

llCastRay(start, start+<60.0,0.0,0.0>*llGetCameraRot(), [RC_REJECT_TYPES, RC_REJECT_LAND | RC_REJECT_PHYSICAL | RC_REJECT_NONPHYSICAL, RC_DETECT_PHANTOM, FALSE, RC_DATA_FLAGS, RC_GET_ROOT_KEY, RC_MAX_HITS,1]);

I assumed that this will allow my llCastRay to penetrate any objects until it finally hits an avatar. Then I realized there is a problem. I *think* llCastRay doesn't seem to detect the avatar if it happens to hit some physical attachments worn on the victim's av. Therefore, The victim doesn't register as getting a hit. Am I mistakened?

What would be the best filter to put so that I would have a high chance to hit the Avatar and nothing else? llCastRay also shoots such a tiny ray that it is almost impossible to shoot someone who is moving around fast.  aAe there any suggestions or advice i can take on how i can make it eaiser to shoot a victim?

 

Link to comment
Share on other sites

llCastRay will not detect attachments. It only detects objects known to the physics system, which means they have to be solid.

Well, yes, it's hard to hit someone who is moving around fast. Try using "touch" detection with mouselook, rather than ray casting. That allows better aim.

Link to comment
Share on other sites

Two fun facts:

  • An avatar that is standing up is shaped like an oblong sphere for raycast. This sphere is smaller than the avatar's hitbox (from render metadata).
  • An avatar that is "sitting on ground" is shaped like a pyramid with a flat tip.
4 hours ago, Xander Lopez said:

llCastRay also shoots such a tiny ray that it is almost impossible to shoot someone who is moving around fast.  aAe there any suggestions or advice i can take on how i can make it eaiser to shoot a victim?

Shoot multiple rays, either parallel to each other or starting from the same point but diverging by some degrees.

Edited by Wulfie Reanimator
  • Like 1
Link to comment
Share on other sites

@animats Thanks for clarifications on the attachments. I feel like llCastRay was not the only answer to weapon system.  I am recently exploring lsl scripting and more insight on this "touch detection" would be helpful.  Could you give me some example syntax I could be using or any reference to lsl wiki page so where I can start reading documentation on touch detection? How does that concept exactly work? Does it detect anything that are touchable? 

 

@Wulfie Reanimator That is quite interesting that avatar would appear like a oblong sphere for cast ray.  I thought it would be some kind of cube block or something....  So if I shoot multiple rays, i guess more than one rays could detect the same avatar. Does that mean those rays will report the victim multiple times and may take multiple damage while the victim actually got hit once?

 

 

Link to comment
Share on other sites

From what I've seen, the standing avatar is not really a oblong sphere but instead more like a low poly coffin shape. There is a picture on the wiki in which someone created an in-world ray tracer visualizer for what the physics shapes look like. Pictured below are the standing avatar (left) and ground sitting avatar (right):

http://wiki.secondlife.com/wiki/File:Avmeshforms.png

And there is in fact a third shape for avatars when they are sitting on prims. I captured this with my own ray tracer I built in-world (inspired by the above picture).

https://my.secondlife.com/fenix.eldritch/snapshots/5c955bc8d774f802cf000001

And lastly, pathfinding characters actually genuinely have a capsule shape as advertised.

https://my.secondlife.com/fenix.eldritch/snapshots/5ca9f4d373ed1711d1000001

My ray tracer is still setup in my workshop (SLURL in the above feed links) if anyone wants to mess around with it. Note it takes about 5 minutes to complete the render.

Edited by Fenix Eldritch
Link to comment
Share on other sites

Back on topic,

25 minutes ago, Xander Lopez said:

So if I shoot multiple rays, i guess more than one rays could detect the same avatar. Does that mean those rays will report the victim multiple times and may take multiple damage while the victim actually got hit once?

This would depend upon how you process the results of the rays. If you fire a burst of rays for a single "shot" then you would have to examine the results from each ray. When comparing the resulting lists, you can make a note of any duplicate keys and elect to ignore them. Off the top of my head, I would basically have a routine that combines the results from all the seperate ray casts and only adds victims if their uuid isn't already in the combined list.

  • Like 1
Link to comment
Share on other sites

"Touch" detection will work if everyone in your game agrees to wear a scripted outfit that is touchable -- a suit of armor or a flack vest, maybe. Script that item  to send a signal to you if you have clicked on it with your mouse (or, maybe, if you have it scripted as a collision detector and have hit it with a physical projectile).

Edited by Rolig Loon
typos, of course
Link to comment
Share on other sites

7 hours ago, Xander Lopez said:

So if I shoot multiple rays, i guess more than one rays could detect the same avatar. Does that mean those rays will report the victim multiple times and may take multiple damage while the victim actually got hit once?

You would get multiple results, but raycast doesn't cause damage on its own. Like @Fenix Eldritch said, you would have to process the results in a way that makes sense for you.

If you used 3 rays in a triangle shape, for example, you could have 3 separate variables for each ray's result, and check those results in some set order to choose which ray is the "most important" for a hit. If RayA has a result, damage that avatar and ignore the rest. If RayA didn't hit, check RayB, etc.

Also, regardless of how many rays you shoot (As few as possible! Rays can fail to cast completely if the sim is busy.) you should figure out what the expected maximum range for your weapon is, and then figure out the "width" of your raycasted shot, and then remember that you're shooting at a target about 0.2 - 0.4 meters wide. Your maximum spread should not be much greater than the width of your target (<0.5) at maximum range. Parallel rays are the simplest solution so you won't need to calculate an angle and you'll have the advantage of the maximum width of the shot regardless of distance.

6 hours ago, Fenix Eldritch said:

From what I've seen, the standing avatar is not really a oblong sphere but instead more like a low poly coffin shape. There is a picture on the wiki in which someone created an in-world ray tracer visualizer for what the physics shapes look like. Pictured below are the standing avatar (left) and ground sitting avatar (right):

http://wiki.secondlife.com/wiki/File:Avmeshforms.png

Ah, I had only tested it with an array of "visual lasers" that used raycast to determine their length. They seemed to form a spherical shape, close enough I suppose but interesting to see.

6 hours ago, Fenix Eldritch said:

And there is in fact a third shape for avatars when they are sitting on prims. I captured this with my own ray tracer I built in-world (inspired by the above picture).

https://my.secondlife.com/fenix.eldritch/snapshots/5c955bc8d774f802cf000001

This one even I didn't know about!

Edited by Wulfie Reanimator
Link to comment
Share on other sites

Thank you all for sharing all the knowledge! I have decided to cast 3 rays with the same filter i mentioned in the very first post.  It seems like the easiest solution i can come up with my given skills.

speaking of the multiple rays, I came up with the following:

 

list results1 = llCastRay(start+<0.5,1.5,0.5>, start+<60.0,1.5,0.5>*llGetCameraRot(),[RC_REJECT_TYPES, RC_REJECT_LAND | RC_REJECT_PHYSICAL | RC_REJECT_NONPHYSICAL, RC_MAX_HITS,2]);

list results2 = llCastRay(start+<0.5,0.0,0.5>, start+<60.0,0.0,0.5>*llGetCameraRot(),[RC_REJECT_TYPES, RC_REJECT_LAND | RC_REJECT_PHYSICAL | RC_REJECT_NONPHYSICAL, RC_MAX_HITS,2]);

list results3 = llCastRay(start+<0.5,-1.5,0.5>, start+<60.0,-1.5,0.5>*llGetCameraRot(),[RC_REJECT_TYPES, RC_REJECT_LAND | RC_REJECT_PHYSICAL | RC_REJECT_NONPHYSICAL, RC_MAX_HITS,2]);

I am assuming that these are all parellel, and 1.5 meters apart from each other.  But without the actual visualization of the ray, it is really hard to tell if I am going into the right direction??

Edited by Xander Lopez
adding some more questions hehehe
Link to comment
Share on other sites

5 hours ago, Xander Lopez said:

list results1 = llCastRay(start+<0.5,1.5,0.5>, start+<60.0,1.5,0.5>*llGetCameraRot(),[RC_REJECT_TYPES, RC_REJECT_LAND | RC_REJECT_PHYSICAL | RC_REJECT_NONPHYSICAL, RC_MAX_HITS,2]);

list results2 = llCastRay(start+<0.5,0.0,0.5>, start+<60.0,0.0,0.5>*llGetCameraRot(),[RC_REJECT_TYPES, RC_REJECT_LAND | RC_REJECT_PHYSICAL | RC_REJECT_NONPHYSICAL, RC_MAX_HITS,2]);

list results3 = llCastRay(start+<0.5,-1.5,0.5>, start+<60.0,-1.5,0.5>*llGetCameraRot(),[RC_REJECT_TYPES, RC_REJECT_LAND | RC_REJECT_PHYSICAL | RC_REJECT_NONPHYSICAL, RC_MAX_HITS,2]);

I am assuming that these are all parellel, and 1.5 meters apart from each other.  But without the actual visualization of the ray, it is really hard to tell if I am going into the right direction??

I don't think that's correct, but it's close. How do you calculate start?

For example, if start is llGetPos (avatar pos at <10,10,10>), you're calculating:

raycast_start   = <10,10,10> + <0.5,0.0,0.5>;
raycast_end     = <10,10,10> + <60.0,0.0,0.5>*llGetCameraRot();

Your raycast starts 0.5 meters above and to the East of the avatar, regardless of where they're facing. The ray might hit the user itself. Add the camera rotation to raycast_start as well and then it's correct.

But if start is llGetpos*llGetCameraRot, you'd be calculating:

raycast_start   = <10,10,10>*llGetCameraRot() + <0.5,0.0,0.5>;
raycast_end     = <10,10,10>*llGetCameraRot() + <60.0,0.0,0.5>*llGetCameraRot();

// When avatar rotation: <0,0,90> degrees
raycast_start   = <-10,10,10> + <0.5,0.0,0.5>;
raycast_end     = <-10,10,10> + <60.0,0.0,0.5>*llGetCameraRot();

Which would be just completely bonkers.

Debugging raycasts is definitely hard since there's no way to automatically visualize them. What I do is rez prims at the starting point, facing towards the calculated direction.

Edited by Wulfie Reanimator
Link to comment
Share on other sites

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