Vectors
#1

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.
Reply
#2

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
Reply
#3

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?
Reply
#4

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;
}
Reply
#5

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

GetXYInFrontOfPoint()
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)