# TutorialAlternate for external World to screen

#### kaz

##### Coder
Full Member
Nobleman
Can this thread be moved to the correct place?

I've seen so many threads about "WORLD TO SCREEN HARD TO FIND" after fleep released his ESP tutorial.
This tutorial basically does an alternate using math, world to screen is not used at all in this.
You will need aimbot angle and your view angle, so this will be really easy to implement into your aimbot if its external and writes memory.

Get your current view and subtract it from the aimbot angle.
float Xdif = Enemy.AimbotAngle[1] - ViewX;
since your FOV is only 90 (CSS example) you will have 45 left, 45 right.
you will have to get your window size and divide it by 90(which is the FOV)
GetWindowRect(FindWindow(NULL, "Counter-Strike Source"), &m_Rect);
int dx = (m_Rect.right-m_Rect.left)/90;

pixels are only positive. so if you are aiming left of the aimbot angle then it will be negative values.
the FOV is only 90 so we add what's half of that to the Xdif
Xdif += 45;

Now you have a value like 0 through 90 (the only important ones)
0 is the very left of the screen and 90 is the very right, but this is only if your resolution is 90,90 which would be impossible to play anyways.
So multiply Xdif * dx

If you did all the math correctly then you should have the new x position to draw the ESP box.
I'll use an image I'm going to wrap up in photoshop to try to make this more simple.

Your resolution can't get below 0 so we will add 45 which is half of the FOV
The red line is the Aimbot angle - myview(13+45)

since your resolution is NOT 90, 90
we will do some math here: current resolution (eg:800) / 90
This is 8.88888888....
Now if you multiply 8.9 to your aimbotangle - myview (58) Then you will have the correct amount of pixels to start drawing the ESP.
or the X value.

using my example to draw my ESP I have to draw 516 pixels from the left of my CSS

repeat this process for the Y and you will have your X and Y positions for the ESP

Credits all go to me and algebra.

Last edited:

#### squeenie

##### Hacker
Meme Tier VIP
Dank Tier Donator
That's sweet as man, thanks for sharing.

#### Martinek951

##### Newbie
Full Member
I know this thread is old but hopefully. What if the player angles are not 0-360 but -infinity to +infinity. If I spin 5 times to the right, my xAng would be 3.56454 for example. Then if I spin 1 time around to the left, the ang would be 2.54648

------resolved-----
-I did not realise it's radians....

Last edited:

#### HexMurder

##### Arcane Hacker
Dank Tier VIP
Dank Tier Donator
Speaking of this old thread, i have always found it very interesting but i could never manage to get it to work... Anyone have a more in depth explanation on this?

#### Broihon

##### edgy 12 y/o
Escobar Tier VIP
Fleep Tier Donator
Speaking of this old thread, i have always found it very interesting but i could never manage to get it to work... Anyone have a more in depth explanation on this?
Problem with this is that it's simply incomplete. It won't be accurate. This is basically what's going on (sorry for shitty paint):

d: distance to near plane in world coordinates
a: angle between current yaw and aim angle (so a = yaw - aim_yaw)
b: Fov angle/2
Point P: own player/cam position (x/z coord)
Point E: enemy position (x/z coord)
Green Point: point on near plane where you have to draw the enemy

The main problem with this method is that you have to know how far the near plane is away from the player camera. The near plane is basically your screen. When you know the distance from the camera to the near plane or the width of the near plane in world coordinates you can easily calculate the ScreenX coordinate using similar triangles and trigonometry.

Edit: I might be completely wrong btw. Just saying.

Actually it is really easier:

Last edited:

#### HexMurder

##### Arcane Hacker
Dank Tier VIP
Dank Tier Donator
Вroihon;48292 said:
Actually it is really easier:
I feel like this method would work very well for older games, but i am just misunderstanding something perhaps? The results i am getting with csgo are def wrong.
https://i.gyazo.com/c15db0fc2f05c5ddd589a94167bc00f8.mp4

The 2 in that video is being drawn with the W2S function. And the line is being drawn with this.
I orignially wrote it like this. (very sloppy but just for testing)
C++:
``````int FOV = 90;

float xDif = Engine.enemy[j].aimbotAngle.x - Engine.LocalPlayer.viewAngles.x;
int dx = Engine.screenSize.x / FOV;
xDif += FOV / 2;
xDif *= dx;

float yDif = Engine.enemy[j].aimbotAngle.y - Engine.LocalPlayer.viewAngles.y;
int dy = Engine.screenSize.y / FOV;
yDif += FOV / 2;
yDif *= dy;``````
but i was getting strange results. xDif would be between ~0 to ~1080, and yDif would be between ~0 to ~-1920. When it should be x 0 to 1920 and y 0 to 1080.

so i did it again but this time calulated it with opposite screen coords.

C++:
``````int FOV = 90;

float xDif = Engine.enemy[j].aimbotAngle.x - Engine.LocalPlayer.viewAngles.x;
int dx = Engine.screenSize.[COLOR="#00FFFF"][B]y[/B][/COLOR] / FOV;
xDif += FOV / 2;
xDif *= dx;

float yDif = Engine.enemy[j].aimbotAngle.y - Engine.LocalPlayer.viewAngles.y;
int dy = Engine.screenSize.[COLOR="#00FFFF"][B]x[/B][/COLOR] / FOV;
yDif += FOV / 2;
yDif *= dy;``````
And i also assigned them opposites as well.
C++:
``Vec3 drawingPoint = new Vec3(1920 - yDif, xDif, 0);``
obviously there is something very wrong, because i had to do a lot of stupid things to even get this thing to half ass work. Help pls lmao.

#### Broihon

##### edgy 12 y/o
Escobar Tier VIP
Fleep Tier Donator
I feel like this method would work very well for older games, but i am just misunderstanding something perhaps? The results i am getting with csgo are def wrong.
https://i.gyazo.com/c15db0fc2f05c5ddd589a94167bc00f8.mp4

The 2 in that video is being drawn with the W2S function. And the line is being drawn with this.
I orignially wrote it like this. (very sloppy but just for testing)
C++:
``````int FOV = 90;

float xDif = Engine.enemy[j].aimbotAngle.x - Engine.LocalPlayer.viewAngles.x;
int dx = Engine.screenSize.x / FOV;
xDif += FOV / 2;
xDif *= dx;

float yDif = Engine.enemy[j].aimbotAngle.y - Engine.LocalPlayer.viewAngles.y;
int dy = Engine.screenSize.y / FOV;
yDif += FOV / 2;
yDif *= dy;``````
but i was getting strange results. xDif would be between ~0 to ~1080, and yDif would be between ~0 to ~-1920. When it should be x 0 to 1920 and y 0 to 1080.

so i did it again but this time calulated it with opposite screen coords.

C++:
``````int FOV = 90;

float xDif = Engine.enemy[j].aimbotAngle.x - Engine.LocalPlayer.viewAngles.x;
int dx = Engine.screenSize.[COLOR="#00FFFF"][B]y[/B][/COLOR] / FOV;
xDif += FOV / 2;
xDif *= dx;

float yDif = Engine.enemy[j].aimbotAngle.y - Engine.LocalPlayer.viewAngles.y;
int dy = Engine.screenSize.[COLOR="#00FFFF"][B]x[/B][/COLOR] / FOV;
yDif += FOV / 2;
yDif *= dy;``````
And i also assigned them opposites as well.
C++:
``Vec3 drawingPoint = new Vec3(1920 - yDif, xDif, 0);``
obviously there is something very wrong, because i had to do a lot of stupid things to even get this thing to half ass work. Help pls lmao.
Again, this won't work because it treats numbers as linear functions even though you're dealing with angles shit. That's why it gets to far left/right and up/down. Your code is as correct as possible with this method.
You have to do the maths for the shitty diagram I posted if you want an FOV based w2s.

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