06.01.2014, 04:13
Hello, just a question I can't figure out,
How do I get a camera facing the player regardless what angle their facing?
How do I get a camera facing the player regardless what angle their facing?
CMD:lookatmyself(playerid, params[])
{
new Float:a, Float:x, Float:y, Float:z, Float:oldx, Float:oldy;
GetPlayerPos(playerid, oldx, oldy, z);
GetPlayerFacingAngle(playerid, a);
if(GetPlayerVehicleID(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
x = oldx + (4 * floatsin(-a, degrees));
y = oldy + (4 * floatcos(-a, degrees));
SetPlayerCameraPos(playerid, x, y, z);
SetPlayerCameraLookAt(playerid, oldx, oldy, z);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/lookatmyself", true) == 0)
{
new Float:a, Float:x, Float:y, Float:z, Float:oldx, Float:oldy;
GetPlayerPos(playerid, oldx, oldy, z);
GetPlayerFacingAngle(playerid, a);
if(GetPlayerVehicleID(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
x = oldx + (4 * floatsin(-a, degrees));
y = oldy + (4 * floatcos(-a, degrees));
SetPlayerCameraPos(playerid, x, y, z);
SetPlayerCameraLookAt(playerid, oldx, oldy, z);
return 1;
}
return 0;
}
You can use this filterscript: https://sampforum.blast.hk/showthread.php?tid=330879
OR Alternatively you can use JernejL's map editor, there is a option for copy camera angle. EDIT: Sorry if I get it wrong. |