• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Get coordinates where the player is looking!
#1
Information 
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
  Reply
#2
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.
Argentinian SA-MP Programmer. Playing since 2013.

  Reply
#3
If I understand what you're looking to do, maybe this could be an option: https://sampwiki.blast.hk/wiki/GetPlayerCameraPos
lost venturas | coming soon
  Reply
#4
(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/GetPlayer...rontVector
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply


Forum Jump: