Jump to content
Ally Whitefalcon

Moving linked object with llSetLinkPrimitiveParams

Recommended Posts

I'm having a problem that is probably due to my overlooking something obvious, but I'm not a programmer and i"m pretty new to scripting, and this has me stumped. Sorry if this is something obvious to most of you.

My real situation is more complicated, but I've been able to reproduce it in a much simpler context. If I create two objects, and link them. I'll name one O1 and the other O2. Then the following script:

    touch_start(integer total_number)
    {
        integer o1;
        integer o2;
        
        integer i =  llGetNumberOfPrims();
        for (; i >= 0; --i)
        {
            string linkName = llGetLinkName(i);
            if (linkName == "O1")
            {
                o1 = i; 
            }
            else if (linkName == "O2")
            {
                o2 = i;
            }
        }
        
        vector pos = llList2Vector(llGetLinkPrimitiveParams(o1, [PRIM_POSITION]), 0);
        llSetLinkPrimitiveParamsFast(o1, [PRIM_POSITION, pos + <0.0, 0.0, 0.1>]);
    }
 

if I do it as written, both O1 and O2 jump .1 m upwards. If I edit it so it's operating on o2, nothing at all happens. I can edit and set the positions, and they do the right thing, but this script either moves both or neither, depending on whether I try to move o1 or o2. 

Are they somehow locked together? I've tried it with a few different groups of linked objects, and I get the same results every time. Can someone tell me what I'm doing wrong? pleeeeeease?

Thanks!

Share this post


Link to post
Share on other sites

Even then, of you move the root prim of a linkset, the entire object will move. To move only the root, you'll need to move the whole thing and then reposition the child prims to put them back where they were. It's awkward,  but remember that "local" means "position relative to the root," so moving the root relative to itself means moving everything.

Share this post


Link to post
Share on other sites

If you add a 3rd prim O3 as the root and make it invisible you can easily move O1 and O2 independently and it will look like what you have in mind.

Not a scripted solution but something to take into consideration. 😎

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...