Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llMovetoTarget from sensor

Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
05-02-2005 19:17
how can i get an object to move to another object detected by llSensor and a sensor event (ie, get the vector of the detected object and use llMoveToTarget). I cannot have a dialog between the two objects telling the other its position because I do own tand can't modify the detected object.
_____________________
Other than that, Mrs. Lincoln, how was the play?
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
05-02-2005 19:28
ill post some code:
CODE
state_entry()
{
llSensorRepeat( "", "", SCRIPTED, range, TWO_PI, rate );
}

sensor(integer number_detected)
{
if ( llDetectedGroup(0) == "" && llDetectedType == SCRIPTED )
{
//llMoveToTarget(
state move;
}
}


also, not sure if lldetectedgroup will return a name, or just true or false. :(
_____________________
Other than that, Mrs. Lincoln, how was the play?
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
05-02-2005 19:33
also, i could use llSetpos, if it would be easier, the object doesn't have to be physical.
_____________________
Other than that, Mrs. Lincoln, how was the play?
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
duh!
05-02-2005 19:37
nvm, lldetectedpos, duh! sorry guys :p
_____________________
Other than that, Mrs. Lincoln, how was the play?
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
05-02-2005 19:41
Here you go:
CODE
state_entry()
{
llSensorRepeat( "", "", SCRIPTED, range, TWO_PI, rate );
}

sensor(integer number_detected)
{ // llDetectedType is a little unnecessary since you're only scanning for SCRIPTED
if ( llDetectedGroup(0) == "")
{
llMoveToTarget(llDetectedPos(0),0.3);
// If you want it to move in the general direction instead, try this:
// float speed = 5;
// llMoveToTarget(llGetPos() + (speed * llVecNorm(llDetectedPos(0) - llGetPos())),0.3);
state move;
}
}
_____________________
---
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
05-02-2005 19:43
ok, thanks alot jeff. again. :D
_____________________
Other than that, Mrs. Lincoln, how was the play?
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
05-02-2005 19:45
From: Jeffrey Gomez
Here you go:
// llMoveToTarget(llGetPos() + (speed * llVecNorm(llDetectedPos(0) - llGetPos())),0.3);
}
[/php]



will this work? llGetPos only works on non-physical objects, and llmovetotarget on physical.... I think?
_____________________
Other than that, Mrs. Lincoln, how was the play?
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
05-02-2005 20:01
You're thinking llSetPos. llGetPos works just fine regardless of physics.
_____________________
---