|
Keith Richter
Registered User
Join date: 27 Jan 2007
Posts: 21
|
10-16-2008 17:21
Okay well after reading the lsl wiki, some other threads, examining an example, and still being completely and totally lost, I return with more questions. I'm trying to make an object point at a person when they are nearby, i'm trying to use llLookAt right now and sensors and the few times i dont get an error message, nothing happens. what i have right now is: llLookAt(llDetectedPos(0),1,1); but it doesnt seem to be doing anything. Other thing i need to do is to get it to stop looking at something after a certain amount of rotation, in other words think of it like a persons head, it cant turn 180 degrees.
|
|
MystressAnna Lovenkraft
Registered User
Join date: 24 Oct 2007
Posts: 28
|
Maybe
10-16-2008 17:52
That Snippet you posted looks like it is going to make the prim look at where it is at
try something more like this
integer target = (look to here)
llLookAt(target,1,1);
|
|
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
|
10-16-2008 19:14
MystressAnna: llLookAt asks for a Vector. llDetectedPos is the right answer here as he said he's using a Sensor.
Keith: Is the calling object Physical?
As for limiting how far it can turn, PI/2 will make the Sensor direction only 90 Deg each direction from Forward, you'll likely need to store the Forward Rotation and how far Left/Right to allow it, but that one I don't know how to do.
EDIT:
entry, rez, whenever... { vector Forward = llRot2Euler(llGetRot()); }
vector MaxAngle = <MaxTilt, MaxUpDown, MaxTurn> // NO idea what equation the resulting Floats of llRot2Euler are. D=
if(llRot2Euler(llGetRot()) - Forward > MaxAngle) { ///Return to Forward }
Just trying to think it out. No idea if that'll work.
|
|
Keith Richter
Registered User
Join date: 27 Jan 2007
Posts: 21
|
10-16-2008 22:23
nah it's not physical.
and i can make it look at a spot at random, i can not for the life of me make it follow the nearest person the sensor is detecting though which is currently the main problem. Though what you said Faust will be worth experimenting once I can work out that kink.
|
|
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
|
10-16-2008 22:32
Yeah. llLookAt only works on Physical objects.
Anyway. If my ideapoking helps any, great. XD
|
|
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
|
10-17-2008 00:14
I created a kind of security camera object which use llLookAt to 'watch' people in my virtual office... it works, but it's not physical.
|
|
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
|
10-17-2008 00:19
Indeed... My mistake, I must have been thinking of RotLookAt or something.
Now that I look it up on the Wiki, looking at the example, I have no idea why it isn't working.
EDIT: A whole lot of Wiki poking later, I came up with this. It points the X axis instead of Z for ease of angle calc. Initial tests seem like the angle check works. >.>
float Range = 20.0; //Configure for "Vision" Distance vector MaxRot = <45, 45, 80>; //Configure for Maximum Turning integer Active; vector Forward;
default { state_entry() { Forward = llRot2Euler( llGetRot() ); } touch_start(integer Number) { if( llDetectedKey(0) == llGetOwner() ) { if(Active) { Active = FALSE; llSensorRemove(); llSetRot( llEuler2Rot(Forward) ); } else { Active = TRUE; llSensorRepeat("", "", AGENT, Range, PI, 1.0); } } } sensor(integer Found) { llStopLookAt(); integer Read; @loop; rotation Rot = llRotBetween( ( <1,0,0> * llGetRot() ), ( llDetectedPos(Read) + <0,0,1> ) - llGetPos() ); vector Euler = ( llRot2Euler(llGetRot() * Rot) - Forward ) * RAD_TO_DEG; if( (llFabs(Euler.x) <= MaxRot.x) && (llFabs(Euler.y) <= MaxRot.y) && (llFabs(Euler.z) <= MaxRot.z) ) { llRotLookAt(llGetRot() * Rot, 3.0, 1.0 ); } else if( Read < Found - 1 ) { Read += 1; jump loop; } else { llSetRot( llEuler2Rot(Forward) ); } } }
|
|
Keith Richter
Registered User
Join date: 27 Jan 2007
Posts: 21
|
10-17-2008 00:54
I managed to get the script to work finally, how you say? By putting in random numbers all over the place. Thanks for the help  , now to figure out the next problem -.- Trying to create a script that works with listens but only looks for keywords. So if the word was 'the' it would trigger for any sentence that contained 'the'. Anyone know the trick to this?
|
|
arton Rotaru
Registered User
Join date: 27 Aug 2007
Posts: 43
|
10-17-2008 01:13
default { state_entry() { llListen(0, "","",""  ; } listen(integer channel, string name, key id, string message) { if (llSubStringIndex(llToLower(message), "the"  != -1){ llOwnerSay("found 'the'"  ; } } }
|