Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vector desired_axis = <148.89938, 139.48409, 0.0>;
- default
- {
- state_entry()
- {
- rotation vRotArc = llEuler2Rot( <0.0, 0.0, 180.0> * DEG_TO_RAD );
- //-- creates a rotation constant, 30 degrees around the X axis
- // Saya - Calculating offset based on the difference between the prims position and the desired axis
- vector currentPos = llGetPos();
- // I don't want to rotate around Z at all, so I remove the Z component of the prim position
- currentPos = <currentPos.x, currentPos.y, 0>;
- vector vPosOffset = currentPos - desired_axis;
- // Produces expected results:
- llSay(DEBUG_CHANNEL, (string)vPosOffset);
- //-- creates an offset one meter in the positive Y direction
- vector vPosRotOffset = vPosOffset * vRotArc;
- //-- rotates the offset to get the motion caused by the rotation
- vector vPosOffsetDiff = vPosOffset - vPosRotOffset;
- //-- gets the local difference between the current offset and the rotated one
- vector vPosRotDiff = vPosOffsetDiff * llGetRot();
- //-- rotates the difference in the offsets to be relative to the global rotation.
- vector vPosNew = llGetPos() + vPosRotDiff;
- //-- finds the prims new position by adding the rotated offset difference
- rotation vRotNew = vRotArc * llGetRot();
- //-- finds rot to continue facing offset point
- llSetPrimitiveParams([PRIM_POSITION, vPosNew,PRIM_ROTATION, vRotNew]);
- llRemoveInventory(llGetScriptName());
- }
- touch_start(integer total_number)
- {
- llSay(0, "Touched.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement