Set Player Face Point? - 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)
+--- Thread: Set Player Face Point? (
/showthread.php?tid=547765)
Set Player Face Point? -
Aerotactics - 25.11.2014
I don't know how the fuck to do this.
I need a function that will set a player's facing angle to look at an X/Y position coords.
This isn't working:
pawn Код:
//Credits to Zeex
stock SetPlayerLookAt(playerid, Float:X, Float:Y)
{
new
Float:pX,
Float:pY,
Float:pZ;
GetPlayerPos(playerid, pX, pY, pZ);
return SetPlayerFacingAngle(playerid, -acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
}
Re : Set Player Face Point? -
MCZOFT - 25.11.2014
PHP код:
SetPlayerFacingAngle
should always be learn from usage General .. look how it's done
PHP код:
SetPlayerFacingAngle(playerid, Float:ang)
i cant see that at your line
PHP код:
SetPlayerFacingAngle(playerid, -acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
check that line again . if that didnt help you that means you dident explain what you want exactly
Re: Re : Set Player Face Point? -
Aerotactics - 25.11.2014
Quote:
Originally Posted by MCZOFT
PHP код:
SetPlayerFacingAngle
should always be learn from usage General .. look how it's done
PHP код:
SetPlayerFacingAngle(playerid, Float:ang)
i cant see that at your line
PHP код:
SetPlayerFacingAngle(playerid, -acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
check that line again . if that didnt help you that means you dident explain what you want exactly
|
I know what SetPlayerFacingAngle is.
For instance, I have 24 unique spawn points that all face the same spot (an x/y coordinate). Instead of finding EVERY SINGLE facing angle, I have a loop to set the facing angle to face a coordinate, the center of a circle.
The stock above is not setting the facing angle accordingly, though.
Re: Set Player Face Point? -
Write - 25.11.2014
pawn Код:
stock SetPlayerLookAt(playerid, Float:X, Float:Y)
{
new Float:Px, Float:Py, Float: Pa;
GetPlayerPos(playerid, Px, Py, Pa);
Pa = floatabs(atan((Y-Py)/(X-Px)));
if (X <= Px && Y >= Py) Pa = floatsub(180, Pa);
else if (X < Px && Y < Py) Pa = floatadd(Pa, 180);
else if (X >= Px && Y <= Py) Pa = floatsub(360.0, Pa);
Pa = floatsub(Pa, 90.0);
if (Pa >= 360.0) Pa = floatsub(Pa, 360.0);
SetPlayerFacingAngle(playerid, Pa);
}
Simple math.