Solved How to Calculate Aimbot Angles ?

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
Hey im currently using this function

C++:
void CMaths::CalcAngles(const vec3_t &source, const vec3_t &dest, vec3_t &ang)
{
    double delta[3] = { (source[0] - dest[0]), (source[1] - dest[1]), (source[2] - dest[2]) };
    double hyp = sqrt(delta[0] * delta[0] + delta[1] * delta[1]);
    ang[0] = (float)(atan(delta[2] / hyp) * RADPI);
    ang[1] = (float)(atan(delta[1] / delta[0]) * RADPI);
    ang[2] = 0.0f;
    if (delta[0] >= 0.0f)
        ang[0] += 180.0f;

}
to calulate the angles between 2 players, but it doesnt give me the right angles, any ideas of how to calculate aimbot angles correctly?
 
Last edited by a moderator:

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
What values does this give for you, tried outputting those? Sure you are writing those values to the right location?
 

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
What values does this give for you, tried outputting those? Sure you are writing those values to the right location?
I'm not writing yet, just outputting it:

EDIT: the output of the X-angles gives me the distance between me and the enemy..
 
Last edited:

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
also when i use

C++:
void CMaths::GetAngleToTarget(vec3_t vTarget, vec3_t source, vec3_t vAngles)
{
	vec3_t deltaVec;
	deltaVec[0] = vTarget[0] - source[0];
	deltaVec[1] = vTarget[1] - source[1];
	deltaVec[2] = vTarget[2] - source[2];

	VectorAngles(deltaVec, vAngles);

	if (vAngles[0] > 180.0f)
		vAngles[0] -= 360.0f;
	else if (vAngles[0] <-180.0f)
		vAngles[0] += 360.0f;

	if (vAngles[1] > 180.0f)
		vAngles[1] -= 360.0f;
	else if (vAngles[1] < -180.0f)
		vAngles[1] += 360.0f;
}
i get vAngles[0] as the distance between me and the enemy :O there must be something wrong with my input...
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
also when i use

C++:
void CMaths::GetAngleToTarget(vec3_t vTarget, vec3_t source, vec3_t vAngles)
{
	vec3_t deltaVec;
	deltaVec[0] = vTarget[0] - source[0];
	deltaVec[1] = vTarget[1] - source[1];
	deltaVec[2] = vTarget[2] - source[2];

	VectorAngles(deltaVec, vAngles);

	if (vAngles[0] > 180.0f)
		vAngles[0] -= 360.0f;
	else if (vAngles[0] <-180.0f)
		vAngles[0] += 360.0f;

	if (vAngles[1] > 180.0f)
		vAngles[1] -= 360.0f;
	else if (vAngles[1] < -180.0f)
		vAngles[1] += 360.0f;
}
i get vAngles[0] as the distance between me and the enemy :O there must be something wrong with my input...
Show your VectorAngles
 

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
C++:
vec3_t, aimAngles;
...
if(enemy...){
esp.fenemydistance = maths.SubVectorDist(esp.validClients[i], esp.myInfo) / 47;        // this gives the distance well
maths.GetAngleToTarget (esp.myInfo.vpos,esp.validClients[i].vpos, aimAngles);         // this gives me the wrong x angle
printf("aim x : %f\n", aimAngles[0]);
}
and this is my vpos
C++:
        myInfo.posx = *(float*)(0x797618);
	myInfo.posy = *(float*)(0x79761C);
	myInfo.posz = *(float*)(0x797620);

...

	myInfo.vpos[0] = myInfo.posx;
	myInfo.vpos[1] = myInfo.posy;
	myInfo.vpos[2] = myInfo.posz;
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
C++:
esp.fenemydistance =[B] maths.SubVectorDist(esp.validClients[i], esp.myInfo) / 47;[/B]        // this gives the distance well
maths.GetAngleToTarget (esp.myInfo.vpos,esp.validClients[i].vpos, aimAngles);         // this gives me the wrong x angle
I have no idea what you are doing.
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
C++:
 esp.validClients[i].vpos
is a vec3_t of the coordinates of the enemy
and

C++:
 esp.myInfo.vpos
are my coordinates
Obviously, got that part, but this:

C++:
esp.fenemydistance = maths.SubVectorDist(esp.validClients[i], esp.myInfo) / 47;        // this gives the distance well
maths.GetAngleToTarget (esp.myInfo.vpos,esp.validClients[i].vpos, aimAngles);         // this gives me the wrong x angle
and I asked could you show me your VectorAngles
 

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
Obviously, got that part, but this:



and I asked could you show me your VectorAngles
Ohh i see sorry, you mean this function?
C++:
void CMaths::VectorAngles(const vec3_t value1, vec3_t angles) {
	float flTmp, flYaw, flPitch;
	if (value1[2] == 0 && value1[0] == 0)
	{
		flYaw = 0;
		flPitch = 270;
	}
	else
	{
		flYaw = (atan2(value1[2], -value1[0]) * 180.f / 3.14159265358979323846) - 180.f;
		if (flYaw < 0)
		{
			flYaw += 360.f;
		}

		flTmp = sqrt(value1[0] * value1[0] + value1[2] * value1[2]);
		flPitch = (atan2(value1[1], flTmp) * 180.f / 3.14159265358979323846);

		if (flPitch < 0)
		{
			flPitch += 360.f;
		}
	}
	angles[0] = flPitch;
	angles[1] = flYaw;
	angles[2] = 0;
}
 

TastyHorror

Coder
Dank Tier Donator
Nobleman
Oct 11, 2012
179
2,268
8
After looking at this my brain is in pain. Why not debug and see which part does not calculate properly? Assuming everything else is correct but your math. Nonetheless, I am sure c5 will respond.
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
Your vectorangles looks ok from here, but don't count on that. I'd rewrite the whole thing with using magnitude or dot product. See if that results the same things, so you know your positions or seomthing else is off.
 

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
allright so when i use this w2s function

C++:
bool CMaths::WorldToScreen(vec3_t WorldLocation, vec3_t mypos, vec3_t viewAngles, vec3_t oaim, int screencenter[2], float fov[2])
{
	Vect3d vLocal;
	Vect3d vTransForm;
	vec3_t aimAngles,vector3;

	v3Right = new Vect3d;
	v3Forward = new Vect3d;
	v3Upward = new Vect3d;

	AngleVectors1(viewAngles);
	vLocal = SubVectorDistV(WorldLocation, mypos);


	vTransForm.x = vLocal.dotproduct(*v3Right);
	vTransForm.y = vLocal.dotproduct(*v3Upward);
	vTransForm.z = vLocal.dotproduct(*v3Forward);

	if (vTransForm.z < 0.01)
		return false;


	// how do i calculate the aim angle? :S
	oaim[0] = vTransForm.x / 5.1;
	
	printf("aim x : %f\n", oaim[0]);
	system("cls");


        // these work good and give me the screen (2d) coordinates
	screenX = screencenter[0] + (screencenter[0] / vTransForm.z * (1 / fov[0])) * vTransForm.x;            
	screenY = screencenter[1] - (screencenter[1] / vTransForm.z * (1 / fov[1])) * vTransForm.y;

	return true;
}
When i do
C++:
oaim[0] = vTransForm.x / 5.1;
It almost works, but ofc i dont want this, but i dont know what else i can do...
this is actually making me crazy...
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
What the hell are you doing, I suggest reading up on some trigonomtery and vectors. Calculating screen position won't help you much in finding the angle to aim at, nor will randomly dividing by 5.1 help (made me chuckle tbh).

Aimbot math isn't that difficult, since you only need 2 angles you can do calculations on just 2 planes. If you are actually up to learning: Try doing an X axis based aimbot first and later add Y axis, that way it should be easier to comprehend the whole math that has to be done. So draw a vector from you to enemy on X plane, then add directional vector, normalize and get an angle between them (many ways to do so). Test and debug along the way so you'll get a better idea of what's going on, what I just said isn't exactly 100% accuratr but mh it's a start for you.
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,101
78,998
2,374
What the hell are you doing, I suggest reading up on some trigonomtery and vectors. Calculating screen position won't help you much in finding the angle to aim at, nor will randomly dividing by 5.1 help (made me chuckle tbh).

Aimbot math isn't that difficult, since you only need 2 angles you can do calculations on just 2 planes. If you are actually up to learning: Try doing an X axis based aimbot first and later add Y axis, that way it should be easier to comprehend the whole math that has to be done. So draw a vector from you to enemy on X plane, then add directional vector, normalize and get an angle between them (many ways to do so). Test and debug along the way so you'll get a better idea of what's going on, what I just said isn't exactly 100% accuratr but mh it's a start for you.
+1

Maybe start with something much easier? A radar maybe? :)
 

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
What the hell are you doing, I suggest reading up on some trigonomtery and vectors. Calculating screen position won't help you much in finding the angle to aim at, nor will randomly dividing by 5.1 help (made me chuckle tbh).

Aimbot math isn't that difficult, since you only need 2 angles you can do calculations on just 2 planes. If you are actually up to learning: Try doing an X axis based aimbot first and later add Y axis, that way it should be easier to comprehend the whole math that has to be done. So draw a vector from you to enemy on X plane, then add directional vector, normalize and get an angle between them (many ways to do so). Test and debug along the way so you'll get a better idea of what's going on, what I just said isn't exactly 100% accuratr but mh it's a start for you.
allright... i will start all over. i think its way easier than i think it is.
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
allright... i will start all over. i think its way easier than i think it is.
Just cool head and patience, where people go wrong is they start overthinking things: "ermahgerd ermahgerd i have 2xXYZ and radians wat to do", when it actually can be super easy (arc tan and a few other calculations - done). Progress step by step, don't take too big jumps and if necessarity draw stuff out on paper.

My 2 cents
 

Liduen

Hacker
Dank Tier VIP
May 19, 2013
702
8,478
33
I use these maths for my aimbot and they work fine. :)
C#:
//x view angle
a = xPlayer - xEnemy;
b = yPlayer - yEnemy;
angle = Math.Atan(b / a) / Math.PI * 180;
if (a > 0) angle = angle - 180;

//y view angle
c = Math.Sqrt(a * a + b * b);
a = zPlayer - (zEnemy + ((predict[target, 2] - predict[eigenePlayerNummer, 2]) * ausgleich));
angle = Math.Atan(a / c) / Math.PI * 180;
idk if this helps, if it doesn't just ignore it, I'm still a newbie ^^
 
Last edited:

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
I use these maths for my aimbot and they work fine. :)
C#:
//x view angle
xangle = Math.Atan((yPlayer - yEnemy) / (xPlayer - xEnemy)) / Math.PI * 180;
if (a > 0) angle - 180;

//y view angle
yangle = Math.Atan((zPlayer - zEnemy) / (Math.Sqrt(a * a + b * b))) / Math.PI * 180;
idk if this helps, if it doesn't just ignore it, I'm a still a newbie ^^
Yes it try'd this too, but it doesn't give me the angle compared to where i am looking at. I mean, when i move to the left from him my angle gets bigger, which is good but when i just look to the left it doesnt get bigger.
Appreciate ur help.
 
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.

Community Mods