18.07.2011, 19:22
Hi,
I'm trying to script a rocket in SA-MP, one that moves around and heads to a given direction using vectors.
The problem is that the X and Y rotation somehow are totally wrong (not in my script, but in SA-MP!).
I found that quote of a post on the SAMP forum on another forum, however, I cant find that post here anymore:
Is there any way to solve this? I can control the rocket when setting the X rotation to zero constantly and only using the Y rotation as "Heading Up / Downwards" rotation (3D) and the Z rotation as "heading to" direction (2D).
However, I cannot move the object in the "aiming" direction, like "straight-forward" is not possible.
Basically, this is my code to get the vectors
Why straight-forward is not possible for me:
Think of this example:
X Rot = 0, Y Rot = 90, Z Rot = 0 -> The rocket is heading directly up in the air
Now calculate where it would fly to using my algorithm, you get 1 for VektX (because of the Cosinus), 0 for Y and 1 for Z. It should be 0 for X, 0 for Y and 1 for Z (its heading directly up in the air).
Any ideas? Thanks in advance!
I'm trying to script a rocket in SA-MP, one that moves around and heads to a given direction using vectors.
The problem is that the X and Y rotation somehow are totally wrong (not in my script, but in SA-MP!).
I found that quote of a post on the SAMP forum on another forum, however, I cant find that post here anymore:
Quote:
The PAWN code is not incorrect, the functions GTA uses to rotate the objects are incorrect. IIRC z rotation is done around the world's z axis, x and y rotation are done around the object's x and y axies respecitvely. |
However, I cannot move the object in the "aiming" direction, like "straight-forward" is not possible.
Basically, this is my code to get the vectors
pawn Code:
VektX = floatcos(CurrentRotZ, degrees);
VektY = -floatsin(CurrentRotZ, degrees);
VektZ = floatsin(CurrentRotY, degrees);
// ...
SetObjectPos(OID, RX - VektX, RY + VektY, RZ + VektZ);
Think of this example:
X Rot = 0, Y Rot = 90, Z Rot = 0 -> The rocket is heading directly up in the air
Now calculate where it would fly to using my algorithm, you get 1 for VektX (because of the Cosinus), 0 for Y and 1 for Z. It should be 0 for X, 0 for Y and 1 for Z (its heading directly up in the air).
Any ideas? Thanks in advance!