Jump to content
Sign in to follow this  
Die neunte Seele

get a vector perpendicular to the screen - any ideas? :)

Recommended Posts

I'm looking for a vector, that shows from the center of the screen to a point x meters ahead of it. The thing you'd try with

ATLtoASL(screenToWorld [0.5,0.5]) 

first.

Sadly, this method only works when you look at the ground or the ocean. When pointed at the sky, x and y are displayed correctly while the z value just gets set 0. :936:

The length of the vector from your screen to the point in the sky seems to be directly related to the viewdistance. But it is higher than the viewdistance. If i knew the relation to the viewdistance (and what else it is related to), i could use it as a radius of a sphere and calculate z with x,y and r. That would solve the problem.

A try with

positionCameraToWorld [0,0,0]

failed, since it gives the position of the camera, but no reference point. The unit / vehicle _player is not in the center of the screen.

eyeDirection has the negligible disadvantage that the camera isn't at the players' eyes (wtf?) and the bigger one, that the head movement cannot follow the camera movement in freelook all the time.

i'm out of ideas! maybe there is some completely obvious thing i miss, since this problem is so basic, that i cannot imagine that it's impossible to do! Do you have an idea? I'm happy about any thoughts!

Share this post


Link to post
Share on other sites

substract positionCameraToWorld [0,0,1] from positionCameraToWorld [0,0,0] and you get a 1meter vector in the direction you're looking.

If you need a specific reference point you could attach an invisible helper-object to a memorypoint of your player and use the position of the helper-object as reference.

You can also get positions of selections directly but that isn't very accurate as it doesn't reflect the exact position of that selection due to animations. The attachTo method is more precise.

Share this post


Link to post
Share on other sites
substract positionCameraToWorld [0,0,1] from positionCameraToWorld [0,0,0] and you get a 1meter vector in the direction you're looking.

If you need a specific reference point you could attach an invisible helper-object to a memorypoint of your player and use the position of the helper-object as reference.

You can also get positions of selections directly but that isn't very accurate as it doesn't reflect the exact position of that selection due to animations. The attachTo method is more precise.

You're my hero! Thanks a lot! :pet11:

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×