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
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.
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