Calculating facing angle cameras by offsetting
#1

Hello, just a question I can't figure out,
How do I get a camera facing the player regardless what angle their facing?
Reply
#2

Kind of confused what you're asking for here.
Do you want the camera to face the player head-on, no matter what way the player is looking?
Does the camera being set belong to the player themselves, or another player looking at this player?
Reply
#3

Yes, the camera is to face the player head-on no matter what way their looking.
And no, the camera to face them self, not another player.
Reply
#4

I don't know where you are using this function, so I put it in a command as an example. I named this command '/lookatmyself'.

ZCMD:
pawn Код:
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;
}
STRCMP
pawn Код:
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;
}
Reply
#5

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.
Reply
#6

Quote:
Originally Posted by iZN
Посмотреть сообщение
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.

@ BenzoAMG, thank you alot! I'll test the code out.

@ iZN, I'm not after getting the camera angle coords but thanks anyways

It's a tricky one to explain
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)