SkyeMariner Posted December 27, 2019 Share Posted December 27, 2019 I'm trying to script an attachment that can sense nearby objects behind the avatar it is attached to. The ideal would be an llSensor function that replaces the arc parameter with two, one the angle the cone is pointing in and the other the spread of the cone, so both in radians. Given there isn't such a function has anyone addressed the problem successfully? My only ideas are working with llCastRay (too resource heavy I suspect) and using llSensor and then determining the direction of the objects discovered. Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted December 27, 2019 Share Posted December 27, 2019 From memory of the wiki, llSensor detects in a cone along the forward X-axis of the prim, so having a narrow cone (less than PI radians) and rotating the attachment so that the X-forward axis is pointing behind the avatar ought to do the trick? In that case, the rotation of the attachment gives you your first requirement, and the sensor angle the second. I might be wrong, the wiki usually isn't, so have a read. Link to comment Share on other sites More sharing options...
Qie Niangao Posted December 27, 2019 Share Posted December 27, 2019 3 hours ago, SkyeMariner said: llCastRay (too resource heavy I suspect) Maybe, unless you're trying to sense specific things that'll be big enough to intersect with a single, well-aimed vector. If that happens to be the case, raycasting should be lower impact than a sensor. (I've noticed it may still glitch-out when used in Physics-intensive regions, but it doesn't add much to the load.) But yeah, if you're scanning all around back there for anything of interest, you're right: you want a sensor.) Link to comment Share on other sites More sharing options...
Lucia Nightfire Posted December 28, 2019 Share Posted December 28, 2019 A dimpled sphere would be a better representation to use since it mirrors the sector and segment a scan "arc" uses, plus the dimpling is orientated along the x axis. Link to comment Share on other sites More sharing options...
SkyeMariner Posted December 28, 2019 Author Share Posted December 28, 2019 Thanks for the responses. llSensor description says "Sensors placed in the root prim of attachments will use the direction the avatar is facing as their forward vector." and " Sensors placed in prims other than the root prim of an attachment will have their forward direction offset relative to the root prim's forward direction, e.g. a sensor in a prim whose +X direction is the reverse of the root +X will look backward." So I guess a child prim as 180 degrees to the root prim would look backwards and do roughly what I want though it would scan a wedge of a cylinder rather than a cone? This may be a silly question but is there a definition of 'forward' somewhere? Do I presume that if I just create a sphere the 'forward' in each dimension would be the direction in which the global co-ordinates increased? Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted December 28, 2019 Share Posted December 28, 2019 (edited) It scans a cone, so the smaller you make the angle, the tighter the cone will be. You could then sweep the child prim to and fro from side to side, recording the relative angle to the root prim when you get a detection. Or, you could use llDetectedPos(...) to get a position vector and work that with the avatar's position to derive the angle between them. Unfortunately the old external site which had an excellent diagram showing the arc of scan is offline, but the LSL Portal page on llSensor does give a good enough description of how it works. Pi scans a full spherical region, pi_by_two a hemisphere (ie forward of the scan centre) so further fractions of PI will tighten the arc of scan. A bit of trig will allow you to work out the chord at the end of a 1 degree arc of a given radius using chord = 2 * (radius * sin (angle / 2)). Edited December 28, 2019 by Profaitchikenz Haiku Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted December 29, 2019 Share Posted December 29, 2019 On 12/28/2019 at 5:42 PM, SkyeMariner said: This may be a silly question but is there a definition of 'forward' somewhere? Do I presume that if I just create a sphere the 'forward' in each dimension would be the direction in which the global co-ordinates increased? Positive X is always considered to be the "forward" direction in Second Life's coordinate system. Link to comment Share on other sites More sharing options...
Recommended Posts
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