22.09.2010, 17:19
Searched thread for SetPlayerCameraPos and it looks like this topic hasn't been covered yet. This function is really handy for setting up the view for OnPlayerRequestClass and can be used for spectating also.
Notes:
camera angle is relative to the map not the player facing angle - this is being addressed for next edit.
mode=true when used in OnPlayerRequestClass - set the appropriate interiorid if not "0"
Notes:
camera angle is relative to the map not the player facing angle - this is being addressed for next edit.
mode=true when used in OnPlayerRequestClass - set the appropriate interiorid if not "0"
Код:
stock AdjustCameraAngle(playerid,mode)
{
new Float:c[3], Float:angle;
new Float:degrad=0.01745329251994;
new Float:p[]={2033.1309,1543.0475,10.8203,90.00}; // playerrequestclass data
new Float:distance = 10.0; // camera distance to player
new Float:offset = 0.00; // camera facing angle
new Float:pitch = 10.00; // camera pitch
if(mode){
SetPlayerPos(playerid,p[0],p[1],p[2]);
SetPlayerFacingAngle(playerid,p[3]);
SetPlayerInterior(playerid,0); // see notes
}
else{
GetPlayerPos(playerid,p[0],p[1],p[2]);
}
angle=offset-180.00*degrad;
c[0]=p[0]+floatsin(angle)*distance;
c[1]=p[1]+floatcos(angle)*distance;
c[2]=p[2]+pitch;
SetPlayerCameraPos(playerid,c[0],c[1],c[2]);
SetPlayerCameraLookAt(playerid,p[0],p[1],p[2]);
}

