Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

I've taught rotations to other people, and I STILL can't figure this out.

Charmande Petion
Registered User
Join date: 4 Jan 2006
Posts: 118
05-30-2007 17:37
Okay, I have a gun on my left arm (attachment), and a missile that will come out of it.

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
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
05-31-2007 02:50
Aren't you forcing the newly-rezzed missile to inherit the avatar's rotation, with:

llRezObject("RoboMissile", pos, <0.0,0.0,0.0>, rot, 0);

and then using that rotation with:

propulsion = llRot2Up(llGetRootRotation()) * 0.2;

, or am I missing the puzzle completely?
Charmande Petion
Registered User
Join date: 4 Jan 2006
Posts: 118
05-31-2007 07:42
Yes, the missile orients itself correctly when rezzed, it is facing forward as it should be, the problem is the it accelerates in different directions depending on which way my avatar is facing. The missile SHOULD always accelerate in it's own llRot2Up() direction, which is essentially forward do to the orientation of the root prim. And like I said, it works perfectly fine when I rez the missile itself from my inventory and let it fly off. When I rez it from my gun attachment, the missile accelerates... well, like I said, it flies straight up when I'm facing west... straight down when facing east... and so on.

I'm so lost x.x
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
05-31-2007 08:17
You're going to smack yourself for this...

From: someone

llSetForce(propulsion, TRUE);


You're setting the force relative to the object's axes, because of that "TRUE", but you calculated it in world coordinates. You could just do llSetForce(<0,0,0.2>, TRUE);, or llSetForce(propulsion, FALSE);. Everything else is correct :)
Charmande Petion
Registered User
Join date: 4 Jan 2006
Posts: 118
05-31-2007 08:29
I'm so stupid. D:

Edit: I should have read the tooltip for llSetForce a little more carefully. >_>

Thanks. :D