SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/09/2013, 07:06 PM   #1
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,883
Reputation: 1321
Default Getting a players aiming vector

Last night I was working on something and it turned out to be useful in another way so I made this filterscript.

http://forum.sa-mp.com/showthread.php?t=463490

There is a problem however with it, that is trying to compensate for where the player is aiming I do have it working fairly close but by no means is it 100 percent accurate.

The main problem lies here.

pawn Code:
// Compensate (This is not perfect yet any ideas anyone?)
    if(weapon != 34 && weapon != 35 && weapon != 36)
    {
        new Float:FacingA;
        GetPlayerFacingAngle(playerid, FacingA);
        FacingA -= 90.0;
        if(FacingA < 0.0) FacingA += 360.0;
        else if(FacingA > 360.0) FacingA -= 360.0;

        fP[0] = (fP[0] + 0.6 * floatsin(-FacingA,degrees));
        fP[2] += 1.2;
    }

It works fine for sniper, and RPGS since the aiming offset is the center of the screen, the problem happens with other weapons even though it is reasonably accurate I would like to improve that accuracy.

So, any ideas of calculating the correct offsets remember were using, the following code to get the vector this is where the compensation needs to be adjusted for.

pawn Code:
GetPlayerCameraPos(playerid, fP[0], fP[1], fP[2]);
    GetPlayerCameraFrontVector(playerid, fV[0], fV[1], fV[2]);
Pottus is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Speed boost - Front vector s3rious Scripting Help 0 19/01/2013 04:21 PM
Draw the shooting vector Reynolds Scripting Help 0 02/05/2012 05:28 PM
How to know if a vector passes over a dot KakarottoSSJ Scripting Help 2 04/12/2011 02:32 AM


All times are GMT. The time now is 10:35 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.