Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Calculating distance

Albert Wake
Registered User
Join date: 5 Jan 2006
Posts: 25
04-06-2006 10:15
How would you work out the distance to a target object/avatar from an object if you had the target keys available? I don't seem to be able to find a llGetTargetPos() function or similar in the wiki.

Thanks in advance.
Kayla Stonecutter
Scripting Oncalupen
Join date: 9 Sep 2005
Posts: 224
04-06-2006 10:21
llVecDist(llGetPos(), TargetPos);

Wiki link
_____________________
Albert Wake
Registered User
Join date: 5 Jan 2006
Posts: 25
04-06-2006 10:29
hey thanks for the function will save me a bit of time.

But is there no way of obtaining the position of a target object or avatar?

Again, Thanks in advance.
Kairen Overdrive
Registered User
Join date: 12 Jul 2005
Posts: 38
04-06-2006 11:21
Yes, with any input event such as a sensor,collision etc.
Kayla Stonecutter
Scripting Oncalupen
Join date: 9 Sep 2005
Posts: 224
04-08-2006 22:03
llDetected* functions. Not all the detection functions work in all events, but in sensors llDetectedPos() will give you the location of someone at the time the sensor was run. Unfortunately, llSensor() and llSensorRepeat() are the only way to get the position of an arbitrary avatar unless you want to rely on the collision or touchevents.
_____________________
Albert Wake
Registered User
Join date: 5 Jan 2006
Posts: 25
04-09-2006 12:10
thanks peeps works great