Possible to get XYZ in front of player without camera vectors?
#1

Hi, i'm using the new camera interpolation funcs added in 0.3e.

The problem is this; I have a camera angle high above the playing field, i want to interpolate the camera from that position and angle - to behind the player and facing in the direction the player is facing. So the cam zooms to behind the player. (same angle player is facing)

This is the func i would normally use to get an xyz co-ordinate in front/behind the player.

pawn Код:
stock TE::GetXYZInFrontOfPlayer(playerid, Float:range, &Float:x, &Float:y, &Float:z)
{
    new
        Float:fPX, Float:fPY, Float:fPZ,
        Float:fVX, Float:fVY, Float:fVZ;
    GetPlayerCameraPos(playerid, fPX, fPY, fPZ);
    GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
    x = fPX + floatmul(fVX, range);
    y = fPY + floatmul(fVY, range);
    z = fPZ + floatmul(fVZ, range);
}
But that obviously wont work if the players camera is facing another direction. Is there another function available to me that doesn't rely on camera vector/pos? Eg, just uses players xyz and angle??

Doesn't matter if its not the most efficient func as long as it works.

Any help would be very much appreciated.
Reply
#2

pawn Код:
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    // Created by ******

    new Float:a;

    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);

    if (GetPlayerVehicleID(playerid)) {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }

    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
Then Z being the same as the player's position (or you could add +1.0). So use GetPlayerPos beforehand.
Reply
#3

Tyvm, needed this a lot. It looked shyte when it didn't go same angle player was facing.

*gives vince a cyber hug*
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)