SA-MP Forums Archive
Vectors - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vectors (/showthread.php?tid=565567)



Vectors - adri1 - 28.02.2015

pawn Код:
new
            Float:fPX, Float:fPY, Float:fPZ,
            Float:fVX, Float:fVY, Float:fVZ;


        GetPlayerObjectPos(playerid, fPX, fPY, fPZ);
        GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
 

//FORWARD
        fPX += floatmul(fVX, fScale);
        fPY += floatmul(fVY, fScale);
        // I not use this fPZ += floatmul(fVZ, fScale);

//BACK
fPX -= floatmul(fVX, fScale);
        fPY -= floatmul(fVY, fScale);

//RIGHT?
//LEFT?
I want to move the object forward, back, right, left depending camera vector.


Re: Vectors - Pottus - 28.02.2015

Basically you mean translate the movement directions based on camera vector? If that is the case you would need to do the following.

1.) Get camera facing angle
2.) Add angle your movement angle (0, 90, 180, 270)
3.) Get the position in front of that angle


Respuesta: Re: Vectors - adri1 - 28.02.2015

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Basically you mean translate the movement directions based on camera vector?
Yes, i guess, my english isn't fluid

EDIT: Ok, thanks Pottus.

EDIT2:
1)Ok
2)Ok
3)3.) Get the position in front of that angle.... How?


Re: Vectors - Pottus - 28.02.2015

Just so there is no confusion here is Nero_3D's function to get the camera facing angle.

pawn Код:
Float: GetPlayerCameraFacingAngle(playerid)
{
    new Float: vX, Float: vY;
    if(GetPlayerCameraFrontVector(playerid, vX, vY, Float: playerid))
    {
        if((vX = -atan2(vX, vY)) < 0.0) return vX + 360.0;
        return vX;
    }
    return 0.0;
}



Re: Vectors - Pottus - 28.02.2015

Just so there is no confusion the last step is this.

GetXYInFrontOfPoint()