Setting a players angle - 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: Setting a players angle (
/showthread.php?tid=432943)
Setting a players angle -
flyde - 25.04.2013
Is there a way to set a players angle towards an object?
Like whenever I call this function it'll set the players angle towards that object?
Re: Setting a players angle -
Ryan_Obeles - 25.04.2013
i think all you could do is look at the object IG then /save angle then when player spawns setplayerfacingangle or spawninfo
Re: Setting a players angle -
verlaj - 25.04.2013
it is possible.
https://sampwiki.blast.hk/wiki/SetPlayerCameraLookAt
Re: Setting a players angle -
Ryan_Obeles - 25.04.2013
ohhh i didnt actually knew that there was a function like that i never even tested it thx for telling that there is such functions
Re: Setting a players angle -
MP2 - 25.04.2013
I have this VERY OLD function from a VERY old script of mine, so it's probably not the best, but it works:
pawn Код:
stock SetObjectFacePlayer(Float:Px, Float:Py, Float:x, Float:y)
{
new Float: 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);
return floatround(Pa);
}
It'll return the z rotation for your object.
Px + Py = Player X/Y coords.
x + y = Object x/y coords.
Doesn't support Z height, but that's generally not needed.
EDIT: There's also this:
http://forum.sa-mp.com/showthread.ph...3D#post1498305