open.mp forum
[Pawn] Get coordinates where the player is looking! - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] Get coordinates where the player is looking! (/showthread.php?tid=2093)



Get coordinates where the player is looking! - Otakeiro - 2021-06-02

I intend to do something similar to the gravitygun while holding an object at 10.0 away the front of the player, but I do not know which function to use so that when the player looks up this object fluctuating following the position to where the player is looking



What function would do that for me? Get the position where the player is looking


RE: Get coordinates where the player is looking! - Chessy - 2021-06-04

You can use something like this

new Float:angle, Float:x, Float:y, Float:z;

GetPlayerFacingAngle(playerid, angle);

GetPlayerPos(playerid, x, y, z);



And from there calculate the coordinates, if he is looking north, you know that in north the Y coordinate increases, if he is looking west, the X coordinate decreases.



Something like

new Float:lookingx, Float:lookingy;

if(angle == 0) // He is looking north

{

lookingx = x; // The already X position of the user

lookingy = y; // The position on Y of the user plus 10 meters.

}

if(angle == 90) // He is looking east

{

lookingx = x; // The already X position of the user plus 10 meters

lookingy = y; // The position on Y of the user.

}



And you'll calculate the angles with some mathematic formula.


RE: Get coordinates where the player is looking! - Schoenherr - 2021-06-05

If I understand what you're looking to do, maybe this could be an option: https://sampwiki.blast.hk/wiki/GetPlayerCameraPos


RE: Get coordinates where the player is looking! - Pinch - 2021-06-05

(2021-06-05, 03:31 AM)Schoenherr Wrote: If I understand what you're looking to do, maybe this could be an option: https://sampwiki.blast.hk/wiki/GetPlayerCameraPos

Combine that with

https://sampwiki.blast.hk/wiki/GetPlayerCameraFrontVector