This client function returns the player's horizontal and vertical angles.
It is used as GetAngle("x"); , returns the same value as player.Angle, and a GetAngle("y"); ", returns the player's vertical Angle. One drawback is that when the player is facing in a positive east-west direction, it is impossible to calculate.
function GetAngle(m)
{
local angle;
local a=GUI.ScreenPosToWorld(Vector(GUI.GetScreenSize().X/2,GUI.GetScreenSize().Y/2,1));
local b=GUI.ScreenPosToWorld(Vector(GUI.GetScreenSize().X/2,GUI.GetScreenSize().Y/2,-1));
if(m=="x") angle=-atan2(a.X-b.X,a.Y-b.Y);
if(m=="y") angle=-atan2(b.Y-a.Y,a.Z-b.Z);
angle=(angle*100).tointeger();
angle=angle.tofloat()*0.01;
return angle;
}
Looks promising. Good job!
Would be awesome to have one for cars too