# SolvedAimbot Math is off

#### B14CKS1D3

##### Newbie
Full Member
My aimbot dosen't really aim where it is suppoed to. Tried a few ways of doing it, and the one that is the closest to the peds is the CalcAngles one.
Here is my function
C++:
``````void CalcAngles(Vec source, Vec Destination, float angles[3]){
float delta[3] = { (source.x - Destination.x), (source.y - Destination.y), (source.z - Destination.z) };
float hyp = sqrt(delta[0] * delta[0] + delta[1] * delta[1]);
angles[0] = (float)(asinf(delta[2] / hyp) * 57.295779513082f);
float theta = (float)(atanf(delta[1] / delta[0]) * 57.295779513082f);//yaw in degrees
if (delta[0] >= 0.0) theta += 180.0f;
/*Code below is because I write to the rotation matrix (There is no yaw only values)*/
theta = theta  * (M_PI / 180.0f) + aimbotOffset;//Deg->Rad
float vX = hyp * cos(theta);
float vY = hyp * sin(theta);
angles[1] = vX;
angles[2] = vY;
}``````
Anyone can help me getting this working? Btw, Vec = 3 floats (x, y, z)

#### Rake

My aimbot dosen't really aim where it is suppoed to. Tried a few ways of doing it, and the one that is the closest to the peds is the CalcAngles one.
Here is my function
C++:
``````void CalcAngles(Vec source, Vec Destination, float angles[3]){
float delta[3] = { (source.x - Destination.x), (source.y - Destination.y), (source.z - Destination.z) };
float hyp = sqrt(delta[0] * delta[0] + delta[1] * delta[1]);
angles[0] = (float)(asinf(delta[2] / hyp) * 57.295779513082f);
float theta = (float)(atanf(delta[1] / delta[0]) * 57.295779513082f);//yaw in degrees
if (delta[0] >= 0.0) theta += 180.0f;
/*Code below is because I write to the rotation matrix (There is no yaw only values)*/
theta = theta  * (M_PI / 180.0f) + aimbotOffset;//Deg->Rad
float vX = hyp * cos(theta);
float vY = hyp * sin(theta);
angles[1] = vX;
angles[2] = vY;
}``````
Anyone can help me getting this working? Btw, Vec = 3 floats (x, y, z)
try this bad boy:
C++:
``````vec3_t CalcAngle(vec3_t src, vec3_t dst)
{
vec3_t angles;
angles.x = (-(float)atan2(dst.x - src.x, dst.y - src.y)) / PI * 180.0f + 180.0f;
angles.y = (atan2(dst.z - src.z, Distance(src, dst))) * 180.0f / PI;
angles.z = 0.0f;
return angles;
}``````

#### B14CKS1D3

##### Newbie
Full Member
Rake;42183 said:
try this bad boy:
C++:
``````vec3_t CalcAngle(vec3_t src, vec3_t dst)
{
vec3_t angles;
angles.x = (-(float)atan2(dst.x - src.x, dst.y - src.y)) / PI * 180.0f + 180.0f;
angles.y = (atan2(dst.z - src.z, Distance(src, dst))) * 180.0f / PI;
angles.z = 0.0f;
return angles;
}``````
PÃ®tch moves up and down when I move my character.
Haven't figured how to convert yaw for the rotation matrix yet with this function
Idk if the fact that the character isn't 100% centered while aiming can do something

Last edited:

#### Rake

PÃ®tch moves up and down when I move my character.
Haven't figured how to convert yaw for the rotation matrix yet with this function
Idk if the fact that the character isn't 100% centered while aiming can do something
Game is in third person view...no idea how to help

#### PwndDepot

##### I has a status
Dank Tier VIP
Trump Tier Donator
Dank Tier Donator
Rake;42193 said:
Game is in third person view...no idea how to help
GTA V is both 3rd person and 1st person, just like battlefront, so switch to first person mode and see if it works I guess

#### B14CKS1D3

##### Newbie
Full Member
GTA V is both 3rd person and 1st person, just like battlefront, so switch to first person mode and see if it works I guess
GTA dosen't use the same memory addresses for first person view, and since I don't ever use first person view in gta, I didn't bother getting the addresses for it

#### B14CKS1D3

##### Newbie
Full Member
Finally figured it out, Thrid person shooter aimbots are the same as first person games. My error was that I wasn't grabbing the right coordinates to do the math from. I ended up using the same math as I posted for the yaw & Rake's math for pitch.

Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

• Fill out the form correctly
• Tell us the game name & coding language
• Post everything we need to know to help you
• Ask specific questions, be descriptive
• Post errors, line numbers & screenshots
• Post code snippets using code tags
• If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.