hint: make a variable where you store the angle of the camera,
pawn Код:
get player Angle - GetPlayerFacingAngle(playerid,&Float:angle);//GetPlayerFacingAngle(0,variable);
Set Player Angle - SetPlayerFacingAngle(playerid,Float:angle);//SetPlayerFacingAngle(0,variable);
and..
stock TurnPlayerFaceToPos(playerid, Float:x, Float:y, Float:z)
{
new Float:angle;
new Float:misc = 5.0;
new Float:ix, Float:iy, Float:iz;
GetPlayerPos(playerid, ix, iy, iz);
angle = 180.0-atan2(ix-x,iy-y);
angle += misc;
misc *= -1;
SetPlayerFacingAngle(playerid, angle+misc);
}
or if this on above doesn't work correctly try this one:
stock TurnPlayerFaceToPos(playerid, Float:x, Float:y, Float:z)
{
new Float:angle;
new Float:ix, Float:iy, Float:iz;
GetPlayerPos(playerid, ix, iy, iz);
angle = 180.0-atan2(ix-x,iy-y);
SetPlayerFacingAngle(playerid, angle);
}
and i can easy make/find more of this things.. just ask lol
edit:
here u got a function to calculate the angle between amera pos an cameralookat:
pawn Код:
stock FaceCoordsToCoords(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2,&Float:rpitch,&Float:ryaw){// credits to lucifer, edit by Gamer_Z, returns 2 angles between positions, first is the pitch = height angle, second is the Z rotation angle in the environiment
new
Float:DX = floatabs(x2-x1),
Float:DY = floatabs(y2-y1),
Float:DZ = floatabs(z2-z1),
Float:yaw = 0,
Float:pitch = 0,
Float:rpitch = 0,
Float:ryaw = 0;
if(DY == 0 || DX == 0){
if(DY == 0 && DX > 0){
yaw = 0;
pitch = 0;
}
else if(DY == 0 && DX < 0){
yaw = 180;
pitch = 180;
}
else if(DY > 0 && DX == 0){
yaw = 90;
pitch = 90;
}
else if(DY < 0 && DX == 0){
yaw = 270;
pitch = 270;
}
else if(DY == 0 && DX == 0){
yaw = 0;
pitch = 0;
}
}else{
yaw = atan(DX/DY);
pitch = atan(floatsqroot(DX*DX + DZ*DZ) / DY);
if(x1 > x2 && y1 <= y2){
yaw = yaw + 90;
pitch = pitch - 45;
}
else if(x1 <= x2 && y1 < y2){
yaw = 90 - yaw;
pitch = pitch - 45;
}
else if(x1 < x2 && y1 >= y2){
yaw = yaw - 90;
pitch = pitch - 45;
}
else if(x1 >= x2 && y1 > y2){
yaw = 270 - yaw;
pitch = pitch + 315;
}
if(z1 < z2)
pitch = 360-pitch;
}
//SetDynamicObjectRot(objectid, 0, 0, yaw);
//SetDynamicObjectRot(objectid, 0, pitch, yaw);
rpitch = pitch;
ryaw = yaw;
}
all things work for me but maybe for you you need to change ex somthing to -180 or something...