# Trying to get 2D X angle through 3D

Im trying to make an aimbot for Call of duty 4 for educational purpose

I tried this: I declared a few variables enemy coords = eX, eY, eZ Player = pX, pY, pZ

Vector length for X, Z

I have 4 conditions if (eX <= pX && eZ < pZ) { VecX = pX - eX; VecZ = pZ - eZ; }

if (eX > pX && eZ <= pZ)
{
VecX = eX - pX;
VecZ = pZ - eZ;
}

if (eX < pX && eZ >= pZ)
{
VecX = pX - eX;
VecZ = eZ - pZ;

}

if (eX >= pX && eZ > pZ)
{
VecX = eX - pX;
VecZ = eZ - pZ;

}


then

    angleA = atan(NSdif/EWdif) * 57.29578;

angleP = (angleA/360);

then I get X Value from the Code

if (eX <= pX && eZ < pZ)
{


angleA = atan(VecX/VecZ) * 57.29578;

  angleP = (angleA/360);

newValue = halfCircle + (0xFFFFFFFF*angleP);

newValue2 = newValue;


}

     if (eX > pX && eZ <= pZ)
{
VecX = eX - pX;
VecZ = pZ - eZ;

angleA = atan(VecX/VecZ) * 57.29578;

angleP = (angleA/360);
newValue = 0xFFFFFFFF - (0xFFFFFFFF*angleP);

}

if (eX < pX && eZ >= pZ)
{
VecX = pX - eX;
VecZ = eZ - pZ;

angleA = atan(VecX/VecZ) * 57.29578;

angleP = (angleA/360);

newValue = halfCircle - (0xFFFFFFFF*angleP);
}

if (eX >= pX && eZ > pZ)
{
VecX = eX - pX;
VecZ = eZ - pZ;

angleA = atan(VecX/VecZ) * 57.29578;

angleP = (angleA/360);

newValue = 0 + (0xFFFFFFFF*angleP);
}


but this gives me far from what is the enemy X pos on screen ?

• What is an aimbot? What value are you trying to calculate? – bubba Dec 30 '15 at 14:07
• an aimbot is where the code finds the 2D coordinates on screen for the enemy so that it can put the aim on the enemy Im trying to find the pitch and yaw, Im trying to get the players 2D coordinates on the screen through my and the enemy's 3D coordinates XYZ, and then getting the angle to aim up, and the rotation angle to rotate to the enemy's position – DanielHei2 Dec 30 '15 at 16:55