Author Topic: Aimbot angle formula  (Read 539 times)

0 Members and 1 Guest are viewing this topic.

Martin951

  • Intentional Cheater
  • **
  • Posts: 35
    • View Profile
Aimbot angle formula
« on: May 29, 2016, 07:55:30 pm »
This post is probably mostly for MrMedic and I really hope he will read it.

How would I get the angle between tho points in VC, when angle is in radians?
Made my first aimbot ever. For vietcong..

M. O.

  • Administrator
  • MasstKer
  • *
  • Posts: 9184
    • View Profile
    • http://www.tkc-community.net
Re: Aimbot angle formula
« Reply #1 on: May 29, 2016, 08:48:18 pm »
If you got the distances, it's just trigonometry (or vector algebra if you choose to use the scalar product approach).

Normally arctan would be a solution, but considering a player centered approach, I would start out with arccos.

Conversion, if neede, from degrees to radians is just: degrees = 360 * radians/2pi

https://en.wikipedia.org/wiki/Trigonometry
Heckling is an art, and game hacking a science.

Martin951

  • Intentional Cheater
  • **
  • Posts: 35
    • View Profile
Re: Aimbot angle formula
« Reply #2 on: May 29, 2016, 09:06:45 pm »
I have a formula that works well if delta Y is greater then 0, if it's less then 0, the it is turned by 180°.
But the biggest problem is PITCH for me currently. While this formula doesn't really work:

float getAnglePitch(float x1, float y1, float z1, float x2, float y2, float z2)
{
   float dX = x2 - x1;
   float dY = y2 - y1;
   float dZ = z2 - z1;
   
   

   float magnitude = sqrt(x1 * x1 + y1 * y1 + z1 * z1);
   float pitch = atan(dZ / magnitude) + PI/2;

   return pitch;
}
Made my first aimbot ever. For vietcong..

M. O.

  • Administrator
  • MasstKer
  • *
  • Posts: 9184
    • View Profile
    • http://www.tkc-community.net
Re: Aimbot angle formula
« Reply #3 on: May 29, 2016, 10:09:41 pm »
Well, there are potentially a couple of problems there, because magnitude may turn out to be the hypotenuse and not the cathethus. Smallest magnitude could solve it, if there's no other issue involved. And you have to know where x y z point in game, and how they relate to pitch. Drawing would be a good approach.

However, if you're looking strictly at the angle, the scalar product can be used, and having a function that calculates angles between arbitrary vectors is really the best option.

If you want the angle between two vectors (x1, y1, z1) and (x2, y2, z2) you do the dot product, i.e. (x1x2+y1y2+z1z2) and divide by the product of their magnitudes. For accuracy reasons I would just do a single sqrt of both expressions in parantheses. Then acos the result.

If you're interested in pitch you just modify the vectors accordingly.

The other approach to get pitch, in a more visual way, is to use spherical coordinates:
https://en.wikipedia.org/wiki/Spherical_coordinate_system
Heckling is an art, and game hacking a science.

Martin951

  • Intentional Cheater
  • **
  • Posts: 35
    • View Profile
Re: Aimbot angle formula
« Reply #4 on: May 29, 2016, 10:30:02 pm »
Nwm I fixed it. Works now. Thanks
Made my first aimbot ever. For vietcong..