Jump to content

Moving an attached item between two preset positions.


Altier Verwood
 Share

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

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

Recommended Posts

Hello forum, I have a simple script I'm making here and it is kind of kicking my butt. 

The script is meant to do one thing, move an attached object between two preset positions and rotations, at the bottom I have it commented, there is an aim and a hold, and when touched the object should move. 
the problem I have run into. is that it moves relative to sim rotation, and I have been trying for hours to fix it. any help here would be appreciated. 

rotation rot_xyzq;
rotation rot_xyza;
default
{

    state_entry()
    {
        vector xyz_angles = <65.35001, 84.95001, 294.54999>; // This is to define a 1 degree change
        vector angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to Radians
        rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation
    }
    touch_start(integer total_number)
    {        
        llSetLocalRot(llGetLocalRot()*rot_xyzq); //Do the Rotation...
        llSetPos(<-0.04494, -0.62486, -0.03175>);
        state hold;
    }
}


    state hold
{
    state_entry()
    {
        vector xyz_angles2 = <270.00000, 4.60001, 90.79999>; // This is to define a 1 degree change
        vector angles_in_radians2 = xyz_angles2*DEG_TO_RAD; // Change to Radians
        rot_xyza = llEuler2Rot(angles_in_radians2); // Change to a Rotation
    }
    touch_start(integer total_number)
    {       
        llSetLocalRot(llGetLocalRot()*rot_xyza); //Do the Rotation...
        llSetPos(<0.63130, -0.06893, -0.01683>);
        state default;
    }
}

//aim
//pos <-0.04494, -0.62486, -0.03175>
//rot <65.35001, 84.95001, 294.54999>

//Hold
//pos <0.63130, -0.06893, -0.01683>
//rot <270.00000, 4.60001, 90.79999>
Link to comment
Share on other sites

I don't think I understand what you're trying to do here. These "xyz_angles" don't appear to be anything like "1 degree change" increments, yet they're being applied incrementally at each state change.

If rather than incremental rotations each state change, you're instead simply trying to swap between two preset positions (as the thread title suggests), perhaps have a setup script use llGetLocalPos and …Rot to find those exact values for each state while attached, then use those as constants directly in this runtime script, using llSetPrimitiveParams with PRIM_POS_LOCAL and PRIM_ROT_LOCAL. 

(More generally, see "Single or Root Prims vs Linked Prims vs Attachments" for a handy table of when to use what.)

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 239 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...