I got a quick lesson on rotation and came up with the next script, but it always launches the rocket to the east no matter what direction I'm facing and although I can mess with the script to make the rocket face in different directions (it spawns facing up in this script) it always faces the same direction.
What I need the rocket to do is spawn facing straight ahead no matter which direction I'm facing and move where I'm aiming the launcher. Any help would be appreciated.
First section of code 1:
CODE
float SPEED = 10.0;
integer LIFETIME = 100;
float DELAY = 5.0;
vector vel;
vector pos;
rotation rot;
integer have_permissions = FALSE;
integer armed = TRUE;
fire()
{
if (armed)
{
armed = FALSE;
rot = llGetRot();
vel = llRot2Fwd(rot);
pos = llGetPos();
pos = pos + vel;
pos.z += 0.75;
vel = vel * SPEED;
llTriggerSound("Bazooka 1", 4.0);
llRezObject("Rocket", pos, vel, rot, LIFETIME);
llSetTimerEvent(DELAY);
}
}
First section of code 2:
CODE
float SPEED = 10.0;
integer LIFETIME = 100;
float DELAY = 5.0;
vector vel;
vector pos;
rotation rot;
rotation rotb;
vector myrot;
rotation myrotex;
integer have_permissions = FALSE;
integer armed = TRUE;
fire()
{
if (armed)
{
rot = llGetRot();
myrot = llRot2Euler(rot);
myrot.y *= RAD_TO_DEG;
myrot.y *= (myrot.y + 90);
myrot.y *= DEG_TO_RAD;
rot = llEuler2Rot(<myrot.x, myrot.y, myrot.z>);
armed = FALSE;
vel = llRot2Fwd(rotb);
pos = llGetPos();
pos = pos + vel;
pos.z += 0.75;
vel = vel * SPEED;
llTriggerSound("Bazooka 1", 4.0);
llRezObject("Rocket", <pos.x + 5, pos.y, pos.z>, vel, rot, LIFETIME);
llSetTimerEvent(DELAY);
}
}