Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sensor - computing arc

Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
09-20-2008 15:45
Hi Pholks... :)

Got a problem with computing the arc of a sensor. What I need is actually a very narrow sensor-arc. I understand that using PI/2 will make the sensor beam like half a sphere in x-direction. But I need more like a beam than a sphere.
I tried using values like PI/10, PI/8, PI/6 - but then it seems the sensor doesn't sense any objects anymore...
Problem is, when I make the arc wider (like PI/4) the longer the distance I use, the more objects fall into the sensor's range.

Approach is to make an object move in a straight direction - but only if there aren't any obstacles in the way. So I use the distance between the actual position and the target to determine the sensor range. But this distance varies. So the longer the distance, the more likely the sensor will sense an obstacle, even if it wouldn't be in the way of my object...

I tried using llSensorRepeat to constantly scan for objects while moving. But this makes the whole thing pretty unpredictable (and not very reliable as well). So what I do is determine the new position and then scan for obstacles in this distance. If there are any obstacles found, I re-compute the new target until I found a new position where no obstacles are on the way...

Any ideas on how to improve this?

Thanks a lot!
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
09-20-2008 15:53
One problem you might be having is that I THINK an object or avatar is only sensed when its CENTER is in the defined arc and range. If you pointed a narrow-beam sensor straight at an avatar's head, for example, it might not notice them. You'd have to point at about the belly button to see the avatar. I'm not completely sure of that, but it's what I recall vaguely from similar projects.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
09-21-2008 04:33
Thanks Hewee!

That explains A LOT! I realized that when my sensor object approaches a well at the bottom of it, it bumps right into it. So the closer the sensor object is to the wall, the bigger the chance that it won't sense it. What a bummer... Hope I'll find a way around that...
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-21-2008 07:02
http://wiki.secondlife.com/wiki/LlTarget
llTarget(pos,range);
not saying i know this for sure, just going by what i read on the wiki, i think it can sense if the target is within whatever range you give it
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
09-21-2008 08:19
Thanks Ruthven.

But llTarget actually just sets a target, which is then used in combination with llMoveToTarget(), to determine whether the object arrived at the set target or not.

My problem is, that I have to sense obstacles that are in between the target and the current position. As Hewee stated, the sensor has to «hit» the obstacle's center, otherwise the sensor-event won't fire... which bugs me big time...
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
09-21-2008 10:00
Well, sometimes one really should pay attention to the KISS-approach :)

Instead of scanning for obstacles, I just added an invisble prim in front of my moving object which passes collision-events to the main script (which then stops the object and re-orientates it).

So it looks like it's «sensing» the obstacle whereas infact it just bumps into them :)
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-21-2008 10:23
From: Haruki Watanabe
Thanks Ruthven.

But llTarget actually just sets a target, which is then used in combination with llMoveToTarget(), to determine whether the object arrived at the set target or not.

My problem is, that I have to sense obstacles that are in between the target and the current position. As Hewee stated, the sensor has to «hit» the obstacle's center, otherwise the sensor-event won't fire... which bugs me big time...


llTarget() uses at_target and not_at_target

if the target is in the range specified it triggers at_target, there for it doesn't matter if it's in the exact position of the target. llMoveToTarget has nothing to do with those functions unless llTarget is called. so if you wanted it to stop within 1 meter of the target it would be

llTarget(targetpos, 1.0);
llMoveToTarget(targetpos, time to take);

and then the at target event that gets triggered

at_target(integer tnum, vector targetpos, vector ourpos)
{
llStopMoveToTarget();
}


so that said, you could use a full sensor to find the object, move to it, and when it's in range, stop moving


edit: nevermind all that, i missread about scanning for obstacles, not the actual target, the collision event sounds like it should work