I’m having a very difficult time getting a 3d world point projected onto an angled perspective camera. I’m making an rts game with the “typical” rts camera, that is, it’s angled at about 45 degrees (actually 55 degrees in my case) looking down on the terrain and unit characters.
The problem is that due to the camera’s angle, the projected point (the unit’s pivot point in this case) onto screen space slowly gets more “off” as the unit approaches the edges of the screen. It doesn’t matter what edge it approaches, top, down, left or right, the point will drift off-center relative to the unit from where it was in the center of the screen.
I did some testing, and found that WorldToScreenPoint (and WorldToViewportPoint) work just find IF (big if) I’m using an orthographic projection, or if I’m using a perspective projection with zero angle to it. Which in the latter case, the perspective camera would basically have to be on the ground to see anything worthwhile.
To me, this means the WorldToScreenPoint function works great, but I somehow have to do some math to account for the angle of the camera. What math or vector manipulation can I do to account for the angle of the camera?
The overall goal, is to get a unit’s position in 3d world space, project it onto the screen, and have that point stay exactly the same relative to the unit no matter where the unit is on-screen.