• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Take the angle of a position
#1
I would like to know how I get the angle of an X, Y,?Z coordinate, To use for example in the function SetPlayerFacingAngle


Example:

stock Float:GetAnglePos(Float:x, Float:y, Float:z) {
?Code..
return angle;
}
Code:
Discord: Marllun#6297
  Reply
#2
Do you mean the angle between some point?and the position of the player?
Always keep in mind that a lot of people are active on this forum in their spare time.

They are sacrificing time they could easily spend on things they would rather do, to help you instead.

  Reply
#3
I guess you want this

https://open.mp/docs/scripting/functions...acingAngle
  Reply
#4
I want to make the player turn the angle to a specific position.



This function does not exist in the SAMP Native functions, please do not come with GetPlayerFacingAngle, SetCameraBehindPlayer.
Code:
Discord: Marllun#6297
  Reply
#5
https://www.burgershot.gg/showthread.php...3#pid10013



You will have to edit the function so you have to enter the x, y and z coordinates instead of playerid (faceplayerid).
  Reply
#6
(2021-02-26, 11:55 PM)Virsenas Wrote: https://www.burgershot.gg/showthread.php...3#pid10013



You will have to edit the function so you have to enter the x, y and z coordinates instead of playerid (faceplayerid).
I know the function was not created by you, but still ...
Wtf, is all this stuff done with floatsub, floatadd and such. None of that is needed as atan2 already takes into account the sign of both arguments in order to determine the quadrant.

This is all that's needed:
PHP Code:
PlayerFacePosition(playeridFloat:xFloat:y)
{
    new 
Float:pxFloat:pyFloat:pz;
    
GetPlayerPos(playeridpxpypz);

    new 
Float:angle atan2(pypx);
    
SetPlayerFacingAngle(playeridangle 90.0); 

The -90.0 is to account for the weird GTA angle orientation. The actual angle between the 2 points is without this subtraction.
Always keep in mind that a lot of people are active on this forum in their spare time.

They are sacrificing time they could easily spend on things they would rather do, to help you instead.

  Reply


Forum Jump: