# How to calculate height of a thought line over a known spot in 3rd person view?

Assuming a player object with third-person-view is in a 3d room and the center of the screen has a dot - let's call it "cursorTarget".

All I have is the position of the player, the position 5 meters in front of it - let's call it "spot" - and (if necessary) the position where the cursorTarget touches the ground if it's below the horizon.

With that given data, is it possible to calculate the height of the (thought) line between player and cursorTarget right above the spot?

I firstly thought of the intercept theorem, but I lack of knowledge of the camera height in that third-person-view.

Kind regards, Stacky

• Are you using any game engine (Unity, for instance)? If so, you probably have the position and height of the camera. An idea would be to normalize the heights from the cursorTarget height (i.e. make it 0, and discount its height to the camera height) and then use the similarity of triangles to calculate the height of spot from the normalized height of the camera and the horizontal distances between the objects. Jul 31, 2015 at 16:15
• I'm not developing the game, I'm modding. So no, I don't use any game engine. As for the idea though, that's a good start but I still don't have the camera height. :( Jul 31, 2015 at 16:21
• I see. Well, what game are you modding? Perhaps you should add this information to the question, since it might help you get better answers from people experienced in that particular game (or in modding in general). Good luck mate. :) Jul 31, 2015 at 16:29
• Pretty sure you're going to need a bit more information than that. Do you know how far back the camera is behind the player? Do you know the angle between the camera and the floor? Do you know the distance between the camera and the point where it intersects with the floor? You're going to need some more data before you can calculate this value, I'm pretty sure. Jul 31, 2015 at 19:02
• I just found out that there is a command I can get the camera position from. So now I know that and I've done some math, but the ratio of the distances (cursorTarget-spot, cursorTarget-cameraPos) is not the same as the ratio of the heights. I assume I'm doing something wrong, because according to the intercept theorem they should be the same. Jul 31, 2015 at 19:35

cameraPosition = positionCameraToWorld [0, 0, 0]; //result = [x, y, z]