The missile starts off non-physical, on_rez it calculates the llRot2Up(llGetRot()) vector, multiplies it by a certain amount, sets the object to physical, and then applies the force vector it calculated.
vector propulsion;
default
{
on_rez(integer start_param)
{
propulsion = llRot2Up(llGetRootRotation()) * 0.2;
llSetStatus(STATUS_PHYSICS, TRUE);
llSetForce(propulsion, TRUE);
}
}
This right here works absolutely flawlessly. I can rez the object, point it in a direction, deselect it, and it will accelerate in the correct direction (which is forward, the missile itself has a cylinder as it's root prim, and that cylinder's llRot2Up(llGetRot()) acts perfectly as a forward vector for the missile.
However, when I place the missile object into my gun, and fire it... the direction that the missile accelerates is depending on which way my avatar is facing. The llRezObject function from my gun is as follows:
rot = llEuler2Rot(<0.0,PI/2,0.0>
* llGetRot(); // This orients my other weapons correctly.pos = llGetPos();
pos = pos - (llRot2Left(rot) * 0.45) + (llRot2Up(rot));
pos.z += 0.25; // These three lines just specify where the missile is appearing in relation to the avatar.
llRezObject("RoboMissile", pos, <0.0,0.0,0.0>, rot, 0);
...As can be seen, I rez this object with a given position, a rotation that works for other weapons (and for this one, it rotates the object corectly), and a vector filled with 0.0 for the velocity (the missile rez's non-physical anyways).
If I'm facing in the global negative-X direction (west), the missile accelerates straight up.
If I'm facing in the global negative-Y direction (south), the missile accelerates straight right.
If I'm facing in the global positive-X direction (east), the missile accelerates straight down.
If I'm facing in the global positive-Y direction (north), the missile accelerates straight left.
...I seriously do not get why this is happening, or how to fix it. I know llGetRot() returns your avatar's rotation if the script is in an attachment. But the script is not in an attachment, the script (that does the accelerating) is in an object that is rezzed FROM an attachment.
Help? Please? Someone? x.x
