Getting Camera Rotation from FrontVector - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Getting Camera Rotation from FrontVector (
/showthread.php?tid=591799)
Getting Camera Rotation from FrontVector -
Spmn - 16.10.2015
I've just reverse-engineered an aimbot cheat and I'm trying to develop a detection tool. Everything went fine until I ran into trigonometry.
I want to get players' Camera Rotation X. (GTA SA Address: 0xB6F258) After some testing, I found out that Cam Rot X is however proportional to GetPlayerCameraFrontVector X and Y Pos.
Any info or snippets are welcomed.
Edit:
This and
this are what I'm looking for. (delete these links if they are against the rules)
Edit 2: I used this function:
Код:
Float: GetPlayerCameraFacingAngle(playerid) // Pottus
{
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;
}
to calculate camera facing angle from Cam Rot X and I found something nice:
Cam Rot X = -PI/2 => Camera Facing Angle = 0
Cam Rot X = 0.0 => Camera Facing Angle = 90
Cam Rot X = PI/2 => Camera Facing Angle = 180
Cam Rot X = PI => Camera Facing Angle = 270
Edit 3:
Finally resolved it thanks to Hiddos:
Quote:
Hiddos: Subtract 90 from the facing angle
Hiddos: Then multiply it with pi/180
|
Re: Getting Camera Rotation from FrontVector -
Spmn - 17.10.2015
I was wrong. After more testing, I found out that Cam Rot X is not dependent to Facing Angle, but to Front Vector X and Y Pos. Also, it looks like Cam Rot X goes from (-pi; +pi)
Re: Getting Camera Rotation from FrontVector -
AbyssMorgan - 17.10.2015
Here you have a collection point in front of you if you come in handy
https://sampforum.blast.hk/showthread.php?tid=591010