Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Does llDetectedPos() return the detected object's center?

Gabriel Noodle
Registered User
Join date: 3 Feb 2006
Posts: 6
02-07-2006 12:50
Hi all,

I'm very very new here to SL and the scripting forums/wiki, so please forgive me if the answer to this question is obvious. =-)

I'm trying to figure out what the position returned by llDetectedPos() is. I know it returns the position of the detected object, but I don't know what that means, exactly. Is this vector the object's center of mass, or is this the closest point on the physical surface of the object to the object doing the detecting, or something else?

Another way to put the question might be to give a little more contect into what I'm trying to do. I'm working on a script that will have objects be able to sense when they've bumped into something and react by moving in a different direction. In order to do this, I'm using the collision event and inside I'm calling llDetectedPos(0) (i'm assuming only one collision) and trying to make sense of the vector returned by that function call. If it's the object's center of mass, and my object collided with this object far away from it's center of mass, it doesn't help me much in determining which axes the collision occured on.

Can anyone help shed some light on this issue for me?

Thanks in advance.
Yours newly,
- Gabriel Noodle =-)
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
02-07-2006 13:19
No, it's always the origin point, the point that comes up if you do an llGetPos, or look in the building tools' position fields.
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog
Gabriel Noodle
Registered User
Join date: 3 Feb 2006
Posts: 6
02-07-2006 13:48
Hmm, okay. So, is there a way for me to detect exactly where I've collided with something? I suppose I could keep a record of previous position and then compare it with my object's position when the collision event fires, then figure out the direction of movement that caused the collision and use that to determine where I've collided with something, but maybe there's a better way?
Ghordon Farina
Script Poet
Join date: 1 Nov 2005
Posts: 126
02-07-2006 14:16
Couldn't you check their pos against yours?

e.g. if object a has pos <10,10,10> and object b has pos <10,10,20> and they collide, then we're pretty sure that object b was above the prim during collision. Thus, you know where they're coming from.

That will give you the axis that the collision occurred at... were you needing something more? Like how fast/what direction each prim was travelling in? Because that'd require a little prediction.
_____________________
<< Script Poet >>
http://ghordon.blog-city.com <--- VISIT ME!
Gabriel Noodle
Registered User
Join date: 3 Feb 2006
Posts: 6
02-08-2006 14:20
>Couldn't you check their pos against yours?

>e.g. if object a has pos <10,10,10> and object b has pos <10,10,20> and they
>collide, then we're pretty sure that object b was above the prim during collision.
>Thus, you know where they're coming from.


Thanks, Ghordon, but will this remain true if the object I'm colliding with is at an angle? My guess is the pos reported by llDetectedPos() will not necessarily have any axis coordinates in common with my object that's colliding with it. Does that make sense?
Tip Baker
Registered User
Join date: 12 Nov 2005
Posts: 100
02-09-2006 00:57
From: Gabriel Noodle
>Couldn't you check their pos against yours?

>e.g. if object a has pos <10,10,10> and object b has pos <10,10,20> and they
>collide, then we're pretty sure that object b was above the prim during collision.
>Thus, you know where they're coming from.


Thanks, Ghordon, but will this remain true if the object I'm colliding with is at an angle? My guess is the pos reported by llDetectedPos() will not necessarily have any axis coordinates in common with my object that's colliding with it. Does that make sense?


Gabriel, both llDetectedPos() and llGetPos() return a vector in region co-ordinates. It makes no difference what the rotation of either object is.
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
02-09-2006 02:35
To transform the region-coordinates into this prim's fram-of-reference, take the offset between the two objects and divide it by this prim's rotation.

IIRC:
CODE
vector RelativeOffset = (llDetectedPos(0) - llGetPos()) / llGetRot();
should tell you where the detected item is, relative to where this prim is, and in which direction it's facing.
Gabriel Noodle
Registered User
Join date: 3 Feb 2006
Posts: 6
02-09-2006 08:03
Thanks, everyone, for your replies. Totally helpfull info. =-)