Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need Distance Between Two Objects

Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
04-06-2007 09:39
heyas;

i'm trying to script a kite system. it is in two parts, the spindle which is held in the hand, and the free-roaming kite part.

now, i want the kite to stay in a certain range of the spindle. what i can't figure out is how to get the kite to find the spindle to calculate the current distance between the two and adjust it, if needed.

i have the key of the spindle... how would i get the position? will a sensor get the distance to the object, somehow? i wasn't able to puzzle it out from the wiki on that.

thanks!
Cindy Crabgrass
Crashed to Desktop
Join date: 9 Sep 2006
Posts: 158
04-06-2007 10:04
See this Radar Script for a good Example.

Let me quote a little part :
CODE

sensor(integer num_detected) {
people=[];
string result;
integer n=-1;
integer distance=0;
integer detDist;
string name;

vector pos = llGetPos();
//get the dist, name and direction of everyone we just scanned.
for(n=0;n<num_detected && n<maxPeople;++n) {
vector detPos = llDetectedPos(n);
detDist = (integer)llVecDist(pos, detPos);
...
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
04-09-2007 06:46
thanks, cindy!