Ok, this is what these 2 scripts should do, 1st the 'Main' script goes into a prim called Master,,, the 2nd script go into another prim called 'Slave',,, and by touching the 'Slave' the 'Slave' will auto align it's self with the 'Master' face to face, but it seems the llSetRegionPos and llSetRot, don't do anything,,,,,I'm sure the calculations are correct, and now I'm stuck.
{L_CODE}:
//PLACE IN MASTER OBJECT TO READ SLAVE OBJECT'S OFFSET AND ROTATION IN RELATION TO MASTER OBJECT
integer iChannel = -67341870;
integer cChannel = -27465144;
list objDetails;
default
{
state_entry()
{
llListen(iChannel, "","","");
}
listen(integer channel, string name, key id, string message)
{
list temp = llGetObjectDetails(id, [OBJECT_POS,OBJECT_ROT]);//Read region position and rotation of child object
vector vMyPos = llGetPos();//Main object's position
rotation rMyRot = llGetRot();//Main object's rotation
vector vChildPos = llList2Vector(temp, 0);//Child object's position
rotation rChildRot = llList2Rot(temp, 1);//Child object's rotation
vector vOffset = (vChildPos - vMyPos)/rMyRot; //calculate how far the child object is from the main object, discounting the main object's rotation
//that is, the offset when the main object is rotated at <0.0,0.0,0.0>
rChildRot = rChildRot / rMyRot;//calculate the child object's rotation when the main object is rotated at <0.0,0.0,0.0>
objDetails = [vOffset, rChildRot];
string objSend = llDumpList2String(objDetails,"|"); // Convert to a string ready for sending to the slave prim.
llRegionSay(cChannel, objSend); // Send the Slave offset and rotation to the Slave.
}
}
and Now the 2nd script:-
{L_CODE}:
//PLACE THIS IN THE CHILD OBJECT TO MAKE IT MOVE INTO THE DESIRED POSITION AND ROTATION IN RELATION TO THE MAIN OBJECT
integer iChannel = -67341870;
integer cChannel = -27465144;
list objDetails;
rotation rRot; // = <0.0, 0.0, -1.0, 0.0>;//fill in desired rotation here, rotation provided by the Master prim
vector vOffset; // = <1.0,0.0,0.0>;//fill in desired offset here, offset provided by the Master prim.
default
{
state_entry()
{
llListen(iChannel, "","","");
llListen(cChannel, "","","");
}
touch_start(integer num_detected)
{
llRegionSay(iChannel,"boo");
}
listen(integer channel, string name, key id, string message)
{
list temp = llGetObjectDetails(id,[OBJECT_POS,OBJECT_ROT]);
vector vObjectPos = llList2Vector(temp, 0);//read target object's position
rotation rObjectRot = llList2Rot(temp,1);//and rotation
// vector vTargetPos = vObjectPos + vOffset * rObjectRot;//calculate the target position, using the target object's frame of rotational reference, not the region's (i.e. relative to the target object)
// rotation rTargetRot = rRot * rObjectRot;//calculate the child object's desired rotation, using the target object's frame of rotational reference
if (channel == cChannel)
{
objDetails = llParseString2List(message,["|"],[]); // Convert the incoming text back into a list.
vOffset = llList2Vector(objDetails, 0); // Separate the offset from the list.
rRot = llList2Rot(objDetails, 1); // Separate the rotation from the list.
// Prepare this slave prim for movement and rotation.
vector vTargetPos = vObjectPos + vOffset * rObjectRot;
rotation rTargetRot = rRot * rObjectRot;
llSay(0, (string)vOffset);
llSay(0, (string)rRot);
// llSay(0, llList2String(objDetails, 0));
// llSay(0, llList2String(objDetails, 1));
llSetRegionPos(vTargetPos);//move to the target position
llSetRot(rTargetRot);//and rotate to face in appropriate direction
}
}
}
Any help would be appreciated.