|
Psyra Extraordinaire
Corra Nacunda Chieftain
Join date: 24 Jul 2004
Posts: 1,533
|
08-31-2006 17:19
This is a modification of Logan Bauer's pet script... I wanted to make a set of eyes for a statue (two unlinked spheres seperate from the rest of the sculpture) that would watch people nearby. Due to not knowing how, I've not messed with the sensor code to get it to detect and "watch" anyone instead of just the owner. That's the first part of things I'd love to know.  The second is.... if you go too far to the side, top, etc... the eyes roll right back into the head. Is there a way to add a limiter so that the eyes only have a, say, 30-degree margin of rotation in all directions so the eyes won't rotate so it's looking into its own head?  //////////////////////////////////////////////////////////////// // Object Face Owner (unlimited turning radius) Script, // // Based on an original script by Logan Bauer. // ////////////////////////////////////////////////////////////////
startup() { vector pos = llGetPos(); llSetStatus(STATUS_ROTATE_X,TRUE); llSetStatus(STATUS_ROTATE_Y,TRUE); llSetStatus(STATUS_ROTATE_Z,TRUE); key id = llGetOwner(); llSensorRemove();
//llSensorRepeat( "", NULL_KEY, AGENT, 10, PI, 1 ) ; llSensorRepeat("",NULL_KEY,AGENT,200,2*PI,.5); }
default { state_entry() { startup();
} on_rez(integer start_param) { startup(); }
sensor(integer total_number) { vector pos = llDetectedPos(0); llLookAt(pos, .1 , 1);
//vector target = llDetectedPos( 0 ) ; //vector mypos = llGetPos() ; //vector grab = llVecNorm( target - mypos ) ; //llLookAt(grab, .1 , 1); } }
_____________________
E-Mail Psyra at psyralbakor_at_yahoo_dot_com, Visit my Webpage at www.psyra.ca  Visit me in-world at the Avaria sims, in Grendel's Children! ^^
|
|
BamBam Sachertorte
floral engineer
Join date: 12 Jul 2005
Posts: 228
|
08-31-2006 19:42
If Vstatue is the vector representing the direction the statue is facing and Vtarget is the vector from the statue to the target avatar then you can use the angle-between-vectors equation: Vstatue . Vtarget = |Vstatue| |Vtarget| cos(angle) if ((Vstatue * Vtarget) / (llVecMag(Vstatue) * llVecMag(Vtarget)) >= llAcos(30 * DEG_TO_RAD)) { llLookAt(avatar region coords) }
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
09-01-2006 01:10
That code should follow the closest av with its eyes.
The llSensorRepeat() line is the part you're looking at. You've got a whole string of things in there:
llSensorRepeat( name , key, type, range, arc, repeat time );
Name and key are optional filters - leave them empty "", "" or "", NULL_KEY and they'll sense whatever things of the required type they can. Putting in "", llGetOwner() in those places will make them track you...
Type is a bit field. For this application AGENT is the only one you need - it senses avies. You've got options for objects too, ACTIVE, PASSIVE, SCRIPTED etc. To detect all objects is ACTIVE | PASSIVE to detect all scripted objects is ACTIVE |PASSIVE|SCRIPTED etc.
Range is a range in m. 96m is meant to be the max range. Near sim edges and things you sometimes wrap to the other edge. It only works in the one sim btw.
Arc is the size of the arc it looks through.
Repeat time is how often to fire again. 0.5 is a fast ping that will chew sim resources, although for this it does make sense.
|