Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Moving linked objects

DrDoug Pennell
e-mail is for old people
Join date: 13 Mar 2007
Posts: 112
10-19-2007 09:42
This is probably the stupidest question ever posted here but

string me = "DazedAndConfused";

I have two objects. I want one to control (move, change the color of) the other. Originally I used llSay() and llListen() to communicate between the two. That worked great - I could do whatever I wanted - move, change color, etc. However it was suggested that I link the objects and use llMessageLinked() and link_message() to communicate between them. I have done that and they communicate nicely.

But when the objects are linked (obviously a requirement for llMessageLinked() etc.) the receiving object won't move. I can change it's color, texture, etc, but it won't move. I'm using llSetPos() for the movement.

What am I missing?

Thanks,

Doug
DrDoug Pennell
e-mail is for old people
Join date: 13 Mar 2007
Posts: 112
10-19-2007 10:11
From: DrDoug Pennell
This is probably the stupidest question ever posted here but

{snippus maximus}

What am I missing?


Um, Nevermind :-0

I just figured out (with the wonderful help of LSLEditor) that I needed to use llGetLocalPos() instead of llGetPos().

Doug
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
10-19-2007 10:25
If you read the wiki entry for llSetPos() at :

http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSetPos

you will see that if llSetPos() is called from a child prim in a link set, then the position is relative to the root prim, and not in region coordinates.

try using this function

moveChildPrim(vector absoluteCoordinates)
{
vector relativePosition = absoluteCoordinates - llGetPos(); // calculate offset from root prim

llSetPos(relativePosition); // move child to this offset
}
_____________________
"Free your mind, and your ass will follow" - George Clinton
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
10-19-2007 12:35
Ace, what you posted seems like a roundabout way to get the value already returned by llGetLocalPos() - which returns the child's offset from the root.
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
10-19-2007 17:00
From: Tiarnalalon Sismondi
Ace, what you posted seems like a roundabout way to get the value already returned by llGetLocalPos() - which returns the child's offset from the root.


No.... It sets the local (child's offset) position.

When the function calculates 'relativePosition = absoluteCoordinates - llGetPos()', its calculating the offset, relative to the root prim of 'absoluteCoordinates', which is exactly where the OP wants to move his child prim.

- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton