Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Get coordinates where the player is looking!

 
  • 0 Vote(s) - 0 Average
Pawn Get coordinates where the player is looking!
Otakeiro
Offline

Burgershot Member
Posts: 15
Threads: 7
Joined: Nov 2020
Reputation: 0
#1
2021-06-02, 08:58 PM
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
Chessy
Offline

Burgershot Member
Posts: 11
Threads: 4
Joined: Feb 2021
Reputation: 1
Location: Argentina
#2
2021-06-04, 04:16 PM
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+10; // The position on Y of the user plus 10 meters.
}
if(angle == 90) // He is looking east
{
lookingx = x+10; // 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.
Schoenherr
Offline

Burgershot Member
Posts: 8
Threads: 1
Joined: May 2021
Reputation: 0
#3
2021-06-05, 03:31 AM
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
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#4
2021-06-05, 05:07 AM
(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
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.
« 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