Burgershot
[Pawn] How can I position the camera in front of the vehicle? - Printable Version

+- Burgershot (https://www.burgershot.gg)
+-- Forum: SA-MP (https://www.burgershot.gg/forumdisplay.php?fid=3)
+--- Forum: Pawn Scripting (https://www.burgershot.gg/forumdisplay.php?fid=10)
+--- Thread: [Pawn] How can I position the camera in front of the vehicle? (/showthread.php?tid=2183)



How can I position the camera in front of the vehicle? - Next - 2021-07-18

I'm trying to make a system where I need to position the camera in front of the vehicle so that it "points" to the vehicle without setting the coordinates in an array, having a "radius" using a GetVehicleModelInfo function.



I managed to do a function where I can get the front of the vehicle using some calculations. But I can't point the camera at the vehicle at the right angle.



PHP Code:
GetVehicleFront(vehicleid, &Float:x, &Float:y)
{
    new Float:aFloat:fSize[3];
    GetVehiclePos(vehicleidxya);
    GetVehicleZAngle(vehicleida);
    GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZEfSize[0], fSize[1], fSize[2]);

    x += (/* radius using fSize? (about 7.5) */ floatsin(-adegrees));
    y += (/* radius using fSize? (about 7.5) */ floatcos(-adegrees));
    return 1;




btw, is this function correct? 


RE: How can I position the camera in front of the vehicle? - JR_Junior - 2021-07-30

PHP Code:
stock Float:GetPosInFrontOfVehicle(vehicleid, &Float:x, &Float:yFloat:distance)
{
    new Float:a;
    GetVehiclePos(vehicleidxya);
    GetVehicleZAngle(vehicleida);
    x += (distance floatsin(-adegrees));
    y += (distance floatcos(-adegrees));
    return a;

PHP Code:
new Float:Pos[3];
GetVehiclePos(GetPlayerVehicleID(playerid), Pos[0], Pos[1], Pos[2]);
SetPlayerCameraLookAt(playerid,Pos[0], Pos[1], Pos[2]);
GetPosInFrontOfVehicle(GetPlayerVehicleID(playerid), Pos[0], Pos[1], 7.0);//If you want the camera to stay behind the vehicle, just put a negative value, for example: -7.0
SetPlayerCameraPos(playeridPos[0], Pos[1], Pos[2]+2.0);//Here you adjust the height of the camera, example: +2.0 



RE: How can I position the camera in front of the vehicle? - Awide - 2021-07-30

Do you want the camera to be in front of the vehicle, and look at the vehicle?