Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Look at you

Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
06-10-2003 19:24
CODE

// Look at you
// Wednesday Grimm
// June 10, 2003
//
// Simple script to demonstrate sensor, hover and llLookAt
//
// Make object this script is on hover above the ground and point its
// forward axis at its owner.

default
{
state_entry()
{
// turn on physics for the object
llSetStatus(STATUS_PHYSICS, TRUE);

// make the object hover 1m above the ground or the water
llSetHoverHeight(1.0, TRUE, 1.0);

// look for owner
llSensorRepeat(
"", // name - anyone
llGetOwner(), // key - the owner
AGENT, // type - agents (avatars)
10.0, // range - search within 10m
PI, // arc - search 360 degrees around
3.0 // rate - search every 3 seconds
);

// This makes the object stay put
llMoveToTarget(llGetPos(), 1.0);
}

sensor(integer n)
{
// point object's forward axis at the detected avatar
llLookAt(llDetectedPos(0), 1.0, 1.0);
}
}
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!
Xylor Baysklef
Scripting Addict
Join date: 4 May 2003
Posts: 109
06-12-2003 14:41
From: someone

PI, // arc - search 360 degrees around


I think you mean 2 * PI ^_~

Xylor
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
06-12-2003 16:28
no he meant pi, since the sensor sweeep seraches positive pi, and then negative pi off about its fwd axis
_____________________
i've got nothing. ;)
Xylor Baysklef
Scripting Addict
Join date: 4 May 2003
Posts: 109
06-12-2003 16:36
From: someone
no he meant pi, since the sensor sweeep seraches positive pi, and then negative pi off about its fwd axis


Aha! Good to know =D

Xylor
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
06-23-2003 22:51
In that case... what does TWO_PI do?
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
06-26-2003 07:58
two_pi is redundant. see diagram. The outer two arcs are a sweep of PI and -PI. The inner circle is a sweep of TWO_PI. for clarity of the diagram i left out the sweep of -TWO_PI; however if it were in there, you would see that they overlap. it should be noted that i haven't acutally tested the intricacies of the sensor event, so i cannot tell you how it it organizes the list(i.e. what it senses first) that it compiles of sensed objects.
_____________________
i've got nothing. ;)
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
06-26-2003 08:23
Thanks Nada, I've been meaning to draw that diagram for a while, but never got a round tuit.

Two notes
1) if you set the arc higher than PI, the sensor will NOT detect any object more than once.

2) the diagram sorta implies that the search area is a circle, it is, in reality, a sphere, or a cut sphere. I realize that drawing it like that would make the diagram much more confusing.
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!
Tcoz Bach
Tyrell Victim
Join date: 10 Dec 2002
Posts: 973
06-26-2003 08:58
Well, mathematically, two pi is required for specifying a full circle sweep in radians. By looking at the arguments, and seeing "radians" as the required unit, it's absolutely reasonable to assume that the correct argument is TWO_PI.

I was uncertain about this as well, as PI seemed to do the job. Letter of the law though, Xylor is correct.
_____________________
** ...you want to do WHAT with that cube? **
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
06-26-2003 09:36
ok so here is a better set of diagrams. This shows a sensor of PI/6.
_____________________
i've got nothing. ;)
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
06-26-2003 09:38
this is the plan view. note that the total arc sensed is PI/3 since it senses from PI/6 to -PI/6, which is 60 degrees.
_____________________
i've got nothing. ;)
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
06-26-2003 09:38
down the y-axis.
_____________________
i've got nothing. ;)
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
06-26-2003 09:39
and finally down the x axis
_____________________
i've got nothing. ;)
Bosozoku Kato
insurrectionist midget
Join date: 16 Jun 2003
Posts: 452
07-20-2003 01:55
Makes me wonder about llSensor().. I used a value of "1" for arc and it seems to look 360deg without much problem. Course I'm running into a ton of other problems with the script I'm working on, so I'm not certain it's (arc) working as intended anyway :p

I think Nada's right though and it's just PI, PI*2 being redunant because it's sweeping 0 to 180 then 0 to -180. Course I suck at math and have been reading trig web sites just to learn the formula for finding radians :p

Boso

p.s. reading trig web sites is not fun.

p.s.s I might soon post another thread about llSensor()/sensor, as I've hit a brick wall and can't figure something out, please have a looksee and see if I've posted. Thanks
Crunch Underwood
Mr. Grown up, Go away sir
Join date: 25 Sep 2007
Posts: 624
02-19-2008 15:15
i blew off the dust and decided to resurect this thread, i have not tested the script so i don't know if it still even works. please tell me if it doesn't as i can't get inworld just now

having almost absolutly no idea about scripts i was wondering if anyone could tell me how to make this script look at the closest avatar? i'm assuming ill just have to change the llGetOwner(), line to something else?

thank you

-Crunch
_____________________
----------------------------------------------

So your final Nimbus Score is 8.15, a quite remarkable achievement for a biped. Congratulations Crunch, you should be very proud. :-)