Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] How can I position the camera in front of the vehicle?

 
  • 0 Vote(s) - 0 Average
Pawn How can I position the camera in front of the vehicle?
Next
Offline

Burgershot Member
Posts: 2
Threads: 1
Joined: Aug 2019
Reputation: 0
#1
2021-07-18, 11:55 PM (This post was last modified: 2021-07-19, 01:48 AM by Next.)
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:a, Float:fSize[3];
    GetVehiclePos(vehicleid, x, y, a);
    GetVehicleZAngle(vehicleid, a);
    GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, fSize[0], fSize[1], fSize[2]);

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



btw, is this function correct? 
JR_Junior
Offline

Burgershot Member
Posts: 20
Threads: 7
Joined: Oct 2020
Reputation: 0
Location: Brasil
#2
2021-07-30, 04:41 AM
PHP Code:
stock Float:GetPosInFrontOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetVehiclePos(vehicleid, x, y, a);
    GetVehicleZAngle(vehicleid, a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
    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(playerid, Pos[0], Pos[1], Pos[2]+2.0);//Here you adjust the height of the camera, example: +2.0 
Awide
Offline

Burgershot Member
Posts: 62
Threads: 5
Joined: Sep 2019
Reputation: 5
#3
2021-07-30, 12:51 PM
Do you want the camera to be in front of the vehicle, and look at the vehicle?
Desolation Roleplay has closed. You can download the gamemode here: https://www.burgershot.gg/showthread.php?tid=2272
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode