Set facing angle to object
#1

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.
Reply
#2

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.
Reply
#3

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
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.
Thank you <3

+rep
Reply
#4

I tried to modify function to set player to look in their left side, but without success, do you have a suggestion?
Reply
#5

You can do it like this:

PHP код:
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playeridx,y,z), GetPlayerFacingAngle(playerida);
+= 90.0//It is +90 or -90 i am not quite sure
+= floatsin(adegrees);
+= floatcos(adegrees);
SetPlayerLookAt(playeridx,y); 
Reply
#6

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
You can do it like this:

PHP код:
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playeridx,y,z), GetPlayerFacingAngle(playerida);
+= 90.0//It is +90 or -90 i am not quite sure
+= floatsin(adegrees);
+= floatcos(adegrees);
SetPlayerLookAt(playeridx,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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)