Jump to content
  • 0

How to get root prim rotation by 2 child buttons?


KennyChidorie
 Share

You are about to reply to a thread that has been inactive for 2298 days.

Please take a moment to consider if this thread is worth bumping.

Question

I need two static buttons what can move(rotate) my prim left/right side. Maybe someone can explain to me what wrong? Thanks for your answers.

Troubles: only 1 button move object. move all objects.

Button:

{
    touch_start(integer k)
    {
        llSay(11111, "Rot1");
        llResetScript();
    }
}

Root:

integer count;

default
{
    state_entry()
    {
        count = 1;
        state p;
    }
}

state p
{
    state_entry()
    {
        llListen(11111, "Rot1", "", "Rot1");
    }
    listen(integer channel, string name, key id, string message)
    {
        rotation rot = llGetRootRotation();
        vector euler = llRot2Euler(rot);
        euler *= RAD_TO_DEG;
        euler += <0, 0, 15>;
        llSay(0, (string) euler);         
        euler *= DEG_TO_RAD;
        rot =  llEuler2Rot (euler);
        llSetRot( rot ); 
}

}

Edited by KennyChidorie
forgot word "rotate", lol
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Many things. From a technical perspective, there's no reason for needing two scripts instead of using only one, and there's no reason to need two states in the script that you have labeled " Root". There should be no need to send messages between the button and the root with chat, either. Because they are in the same linkset, you should be using link messages instead. I also cannot see any reason to reset the "Button" script every single time that you touch it. All in all, you have made the job unnecessarily complicated, although it is clearly rotating the linkset. 

The basic problem, however, is that you have misunderstood the difference between rotating a child prim and rotating the root prim of a linkset. If you rotate the root prim, the entire linkset will always rotate together. You cannot rotate the root prim alone. You have two choices, therefore. The easiest thing to do is to change the way that your linkset is constructed.  Make a different link the root. If you cannot do that, the only other solution is to rotate the root prim and then rotate all of the child prims in the opposite direction so that they appear to have stayed in place. Read the local rotation of each child prim (with llGetLinkPrimitiveParams) and then multiply each one by a rotation in the opposite direction from the rotation you are applying to the root prim.

  • Like 1
Link to comment
Share on other sites

  • 0
22 hours ago, Rolig Loon said:

Many things. From a technical perspective, there's no reason for needing two scripts instead of using only one, and there's no reason to need two states in the script that you have labeled " Root". There should be no need to send messages between the button and the root with chat, either. Because they are in the same linkset, you should be using link messages instead. I also cannot see any reason to reset the "Button" script every single time that you touch it. All in all, you have made the job unnecessarily complicated, although it is clearly rotating the linkset. 

The basic problem, however, is that you have misunderstood the difference between rotating a child prim and rotating the root prim of a linkset. If you rotate the root prim, the entire linkset will always rotate together. You cannot rotate the root prim alone. You have two choices, therefore. The easiest thing to do is to change the way that your linkset is constructed.  Make a different link the root. If you cannot do that, the only other solution is to rotate the root prim and then rotate all of the child prims in the opposite direction so that they appear to have stayed in place. Read the local rotation of each child prim (with llGetLinkPrimitiveParams) and then multiply each one by a rotation in the opposite direction from the rotation you are applying to the root prim.

Thank you, I'll try to fix it.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2298 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...