Set facing angle to object - 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 facing angle to object (
/showthread.php?tid=664253)
Set facing angle to object -
Lunoxx - 23.02.2019
Hello, I don`t know trigonometry verry well and I need some help from you.
I want a function to set player facing to an object. I know position of object and player position, how I can set facing angle?
Thank you in advance.
Re: Set facing angle to object -
Jeffry - 23.02.2019
This might help you:
https://forum.sa-mp.com/showpost.php...53&postcount=4
Get the position of your object and use the function to make the player facing the object.
Re: Set facing angle to object -
Lunoxx - 23.02.2019
Quote:
Originally Posted by Jeffry
|
Thank you <3
+rep
Re: Set facing angle to object -
Lunoxx - 25.02.2019
I tried to modify function to set player to look in their left side, but without success, do you have a suggestion?
Re: Set facing angle to object -
Kaliber - 25.02.2019
You can do it like this:
PHP код:
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid, x,y,z), GetPlayerFacingAngle(playerid, a);
a += 90.0; //It is +90 or -90 i am not quite sure
x += floatsin(a, degrees);
y += floatcos(a, degrees);
SetPlayerLookAt(playerid, x,y);
Re: Set facing angle to object -
NaS - 25.02.2019
Quote:
Originally Posted by Kaliber
You can do it like this:
PHP код:
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid, x,y,z), GetPlayerFacingAngle(playerid, a);
a += 90.0; //It is +90 or -90 i am not quite sure
x += floatsin(a, degrees);
y += floatcos(a, degrees);
SetPlayerLookAt(playerid, x,y);
|
Or just SetPlayerFacingAngle(playerid, a + 90.0);
You convert an angle to a vector, and then convert the same vector to an angle again.