SA-MP Forums Archive
fRotX for SetPlayerAttachedObject - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: fRotX for SetPlayerAttachedObject (/showthread.php?tid=204886)



angle problem - MJ! - 30.12.2010

Hello guys. I found a thing: fRotX it's like the GetPlayerFacingAngle for playerid. I try to make like the arrow, to be with the top at the player. And i used function GetPointAngleToPoint, and i setted fRotX to variabile which i stock GetPointAngleToPoint.

Let's say, the angle between us two, it's 180.0 degrees, and i set the fRotX of arrow to 180.0 degrees, but the arrow doesn't 'look' at him.

What i must to add, or sub ?

Here's the code
pawn Код:
angle = GetPointAngleToPoint(hisposx, hisposy, myposx, myposy);
SetPlayerAttachedObject(playerid, 1, 1318, 1, 1.2532, 0.3623548, 0.0231, angle);



Re: fRotX for SetPlayerAttachedObject - Mauzen - 30.12.2010

There are two different angle systems used in samp (quite confusing, i guess this is a pawn library problem)
Without checking it (correct me if it is wrong, it might be the other way round):
The one, used in GetPlayerFacingAngle etc. is -0 to -180 for the "left side" and +0 to +180 for the "right side". 0 would be north, -90 west, 90 east, +/-180 south.
The other scale is used in floatsin and other float stuff. It counts anticlockwise, from 0 to 360. 0/360 would be north, 90 west, 180 south, 270 east.

To make both compatible with each other, do this:

new Float:angle;
GetPlayerFacingAngle(playerid, angle);
angle = 360 - angle;

In your case this would be:
SetPlayerAttachedObject(playerid, 1, 1318, 1, 0.755045, 0.161908, 0.036331, 360 - angle);


Re: fRotX for SetPlayerAttachedObject - MJ! - 30.12.2010

it doesn.t work ...


Re: fRotX for SetPlayerAttachedObject - Mauzen - 30.12.2010

Ah right, the object rotates together with the player, you have to consider this.

pawn Код:
new Float:pangle;
GetPlayerFacingAngle(playerid, pangle);
pangle = 360 - angle;

angle = GetPointAngleToPoint(hisposx, hisposy, myposx, myposy);
SetPlayerAttachedObject(playerid, 1, 1318, 1, 0.755045, 0.161908, 0.036331, angle - (360 - pangle));
//or:
SetPlayerAttachedObject(playerid, 1, 1318, 1, 0.755045, 0.161908, 0.036331, (360 - pangle) - angle);
That should wok at least better


Re: fRotX for SetPlayerAttachedObject - MJ! - 01.01.2011

Nop, both are wrong ...

/imageshack/img534/5161/blas.png