GetCameraFacingAngle?
#1

Hello, is there a possible way to get the facing of the camera?
I am in need of the camera facing angle or a function like GetCameraFacingAngle.
Thanks.
Reply
#2

mybe this can help you
https://sampwiki.blast.hk/wiki/GetPlayerCameraFrontVector
depending on what you're trying to accomplish
Reply
#3

Quote:
Originally Posted by Golf
Посмотреть сообщение
mybe this can help you
https://sampwiki.blast.hk/wiki/GetPlayerCameraFrontVector
depending on what you're trying to accomplish
Well I am trying to get a Float value just like GetPlayerFacingAngle.
Is there anyway to do it with GetPlayerCameraFrontVector?
Reply
#4

GetPlayerCameraFrontVector
This function returns a vector X, Y, Z of the place where the player is aiming in 3D space from 2D. Yes, you may call this a sort of facing angle.

GetPlayerCameraPos
This generally gives the player camera pos in 3D space.

For making a generall camera for class selection, use those ^^ for reading the cordinates. And then use SetPlayerCameraPos and SetPlayerCameraLookAt for facing angle*.

TIP: you may use map editor for the same purpose. There is camera options at the top in VIEW sub window.
Reply
#5

http://www.geom.uiuc.edu/docs/refere...as/node52.html

Have a look at it it gives you the angle made by vectornwith x y z coords in 3d space

Ps. Its not a coding site its all about vectors...
Reply
#6

Something like this, didnt tested it :
pawn Код:
stock Float:GetCameraFacingAngle(playerid)
{
new Float:pos1[3], Float:pos2[3];
GetPlayerCameraPos(playerid, pos1[0], pos1[1], pos1[2]);
GetPlayerCameraFrontVector(playerid, pos2[0], pos2[1], pos2[2]);
return atan2(pos1[0] - pos2[0], pos1[1] - pos2[1]) * (180 / 3.14);
}
Reply
#7

@BroZeus - Doesn't seem correct too much math here is Nero's solution from some time ago.

pawn Код:
Float: GetPlayerCameraFacingAngle(playerid)
{
    new Float: vX, Float: vY;
    if(GetPlayerCameraFrontVector(playerid, vX, vY, Float: playerid))
    {
        if((vX = -atan2(vX, vY)) < 0.0) return vX + 360.0;
        return vX;
    }
    return 0.0;
}
Texture studio uses this in flymode when creating the texture viewer.
Reply
#8

Quote:
Originally Posted by Pottus
Посмотреть сообщение
@BroZeus - Doesn't seem correct too much math here is Nero's solution from some time ago.

pawn Код:
Float: GetPlayerCameraFacingAngle(playerid)
{
    new Float: vX, Float: vY;
    if(GetPlayerCameraFrontVector(playerid, vX, vY, Float: playerid))
    {
        if((vX = -atan2(vX, vY)) < 0.0) return vX + 360.0;
        return vX;
    }
    return 0.0;
}
Texture studio uses this in flymode when creating the texture viewer.
@Pottus
ok tested ig looks like you are right..
Reply
#9

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
As far as I know the formula i gave should work, too lazy to go in game and test
The camera pos doesn't matter if you only want to know the direction because the native is called CameraFrontVector and not FrontPos (or something similar)
You should have tested the code instead of drawing and uploading that image
Reply
#10

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
The camera pos doesn't matter if you only want to know the direction because the native is called CameraFrontVector and not FrontPos (or something similar)
You should have tested the code instead of drawing and uploading that image
Thanks for that, looks like I was wrong :-/ I thought it returned coords of the point at which camera is pointing at
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)