How to Clamp Angles?
Almost finished with my external aimbot. Its working great. UNLESS i am far above an enemy (like on cat on dust2) and am looking down at him. When i attempt to aim at him i get the bug where you just aim at 0, 0 and the console spams you with an invalid angle message.
So obviously i need to clamp my angles. But even after attempting to clamp them i still get the error. I have tried 2 different ways of doing this and neither of them are preventing me from getting an invalid angle. Here are the two i tried.
- - - Updated - - -
Update: Fixed the problem. It was writing NaN to my view angle. Fixed by simply checking if the value was NaN or not before writing.
- - - Updated - - -
Feel free to close.
So obviously i need to clamp my angles. But even after attempting to clamp them i still get the error. I have tried 2 different ways of doing this and neither of them are preventing me from getting an invalid angle. Here are the two i tried.
Code:
if (x >= 89f)
x -= 89f;
if (x <= -89f)
x += 180f;
if (y >= 180f)
y -= 180f;
if (y <= -180f)
y += 360f;
Code:
while (x > 89.0f)
{
x -= 180.0f;
}
while (x < 89.0f)
{
x += 180.0f;
}
while (y > 180.0f)
{
y -= 360.0f;
}
while (y < -180.0f)
{
y += 360.0f;
}
- - - Updated - - -
Update: Fixed the problem. It was writing NaN to my view angle. Fixed by simply checking if the value was NaN or not before writing.
- - - Updated - - -
Feel free to close.