# SolvedAimbot Y-Angle is Off

#### daveyboy63

##### Newbie
Full Member
Hi,

I'm having a bit of trouble with angle calculation in the vertical direction (ie. 'yaw'). I've been following Fleeps C++ aimbot tutorial, and what follows is a description of my problem, along with the CalcAngle function.

Firstly, the planar angle (left-right, or 'pitch') is correct, always.

However, the yaw is wrong. When I'm on equal level with the enemy, it produces the correct angle. When I'm directly above or below the enemy, it produces the right angle. But as I move the target up from flat ground, more and more will my aim be higher than the enemies position. As I start approaching vertically above, it then becomes more accurate.

So it other words, it generally aims higher than required when the enemy is above you, and lower than required when the enemy is below you.

Does anyone have any suggestions?

C++:
``````void CalcAngle(float *src, float *dst, float *angles)
{
double delta[3] = { (src[0]-dst[0]), (src[1]-dst[1]), (src[2]-dst[2]) };

double hyp = sqrt((delta[0]*delta[0] + delta[2]*delta[2]));

// XMOUSE
angles[0] = (float) (atan2(delta[0], delta[2])) + PI;

// YMOUSE
angles[1] = (float) (atanf(-delta[1]/hyp));``````

Last edited:

#### daveyboy63

##### Newbie
Full Member
What happened to the above ^^^^?

#### Rake

Well, the first post is moderated eventhough I approved it. Maybe it's bugged again. You can recreate the thread under a different name and I'll delete this one.

#### daveyboy63

##### Newbie
Full Member
Sorry.

Anyway, the gist of my problem is that although my horizontal aim is correct, my vertical aim is incorrect.

I am using angles[1] = (float) (atanf(-delta[1]/hyp)); to calculate the angle. And in a normal sense, this IS correct. I went in game and noticed that moving my mouse a little from 0 changed the Y-aim only slightly. But moving my mouse a little from +PI/2 download changed the Y-aim significantly more (ie. 0.05 gap vs 0.2 gap). Furthermore, I recognize that atan(1) = PI/2 -- This is what my formula calculates, HOWEVER, in-game, the correct angle is not this; it's like the aiming is non-linear.

Below is a sample of (x,y,z) coords for me and the enemy, and the calculated angle vs required angle. See the graph for the calculated angle vs. required angle:

Could anyone suggest an improvised formula to determine the correct Y-mouseAngle?

#### maxdd

##### Newbie
Full Member
as soon as i come home ill post you the correct way to do it... i noticed that you are a bit confused on yaw,pitch and roll... it's quite simple if you draw the triangles between you and the enemy.. try to use the asinf or atan2 for the pitch instead

#### daveyboy63

##### Newbie
Full Member
Thank you MaxDD, really looking forward to hearing from you!
(I'm been working on this for ages in great frustration)

#### Public_Void

Dank Tier Donator
Nobleman
Thank you MaxDD, really looking forward to hearing from you!
(I'm been working on this for ages in great frustration)
you are probably using yours and the enemies origin to calculate the angle. Try using your eyepos instead for yourself ans whatever bonepos you wanna aim to.

Attention! Before you post:

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