Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Take the angle of a position

 
  • 0 Vote(s) - 0 Average
Pawn Take the angle of a position
Marllun
Offline

Burgershot Member
Posts: 16
Threads: 3
Joined: Apr 2019
Reputation: 0
#1
2021-02-26, 03:10 PM (This post was last modified: 2021-02-26, 03:12 PM by Marllun.)
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
Freaksken
Offline

open.mp Developer

Posts: 80
Threads: 4
Joined: Feb 2019
Reputation: 6
Location: Belgium
#2
2021-02-26, 04:31 PM
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.
arber
Offline

Burgershot Member
Posts: 11
Threads: 0
Joined: Aug 2020
Reputation: 1
Location: Kosovo
#3
2021-02-26, 07:35 PM
I guess you want this
https://open.mp/docs/scripting/functions/GetPlayerFacingAngle
Marllun
Offline

Burgershot Member
Posts: 16
Threads: 3
Joined: Apr 2019
Reputation: 0
#4
2021-02-26, 11:29 PM
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
Virsenas
Offline

Burgershot Member
Posts: 47
Threads: 0
Joined: Feb 2021
Reputation: 6
#5
2021-02-26, 11:55 PM (This post was last modified: 2021-02-26, 11:57 PM by Virsenas.)
https://www.burgershot.gg/showthread.php?tid=218&pid=10013#pid10013

You will have to edit the function so you have to enter the x, y and z coordinates instead of playerid (faceplayerid).
Freaksken
Offline

open.mp Developer

Posts: 80
Threads: 4
Joined: Feb 2019
Reputation: 6
Location: Belgium
#6
2021-02-27, 12:25 PM (This post was last modified: 2021-02-27, 12:27 PM by Freaksken.)
(2021-02-26, 11:55 PM)Virsenas Wrote: https://www.burgershot.gg/showthread.php?tid=218&pid=10013#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(playerid, Float:x, Float:y)
{
    new 
Float:px, Float:py, Float:pz;
    
GetPlayerPos(playerid, px, py, pz);

    new 
Float:angle = atan2(y - py, x - px);
    
SetPlayerFacingAngle(playerid, angle - 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.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode