Jump to content

Trouble rotating follower 90 degrees forward


Leo1452
 Share

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

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

Recommended Posts

timer()
    {
        list details = llGetObjectDetails(id, [OBJECT_POS, OBJECT_ROT]);
        rotation rot = llList2Rot(details, 1) ;
        llSetPos(llList2Vector(details, 0) + <0.0, -0.5, 0.75>*rot); //The follower floats -0.5 on the y-axis and 0.75 on the z axis from the target
        llSetRot(<rot.x, PI, rot.z, 1>);
    }

This timer is for a follow that follows the object with the UUID of "id." The follower is only to rotate on the z-axis to face the same direction as the target. I want to rotate the object 90-degrees along the y-axis so that its top faces forward instead. However, when I try to set the rotation to <0, 90, 0>, it seems to turn all over the place. I know that there's a mathematical reason why, but I have no idea how to fix this.

Edited by Leo1452
Link to comment
Share on other sites

A "rotation" in LSL is a quaternion. Unless you know exactly what you're doing (mathematically), you should not be touching the individual components as you have.

I would recommend that you work with Euler angles instead (for specific rotations) and convert to Rotations at the end.

To set the object's rotation to <0, 90, 0>, you would use llSetRot(llEuler2Rot(<0, 90, 0> * DEG_TO_RAD)) or llSetRot(llEuler2Rot(<0, PI_BY_TWO, 0>)). Full PI is 180 degrees.

This gets more complicated if you need to follow an object. Coincidentally I've made something similar in this thread:

 

Edited by Wulfie Reanimator
Link to comment
Share on other sites

  • 2 months later...
On 5/26/2021 at 11:38 AM, Quistess Alpha said:
llSetRot(llEuler2Rot(<0,PI_BY_TWO,0>)*rot);

to combine rotations on different axes you need to multiply them together (the order is important as well). (PI_BY_TWO is 90 degrees in radians)

Thank you very much. I have a follow-up question for anyone who can help. I have a non-physical object rotated forward 90 degrees using this line of code. I want to restrict its rotation so that it can only rotate on the z axis. I would code something to nullify the x and y axis rotations so that it's always upright no matter how someone tries to edit the rotation. However, with the object rotated 90 degrees forward, the -x axis replaces the z axis as the new "upright." How do I do this given that the three axes are no longer independent?

Edited by Leo1452
Link to comment
Share on other sites

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