vec_for_screen(VECTOR*, VIEW*): VECTOR*
The opposite of the vec_to_screen instruction. It converts XY screen coordinates, given through the vector, to a world position of the given view. Because a unique 3D position can not be determined from a XY screen position alone, a screen distance must also be given in the Z coordinate of the vector. This function can be used to place entities into a level on mouse click on the screen.
||vector to be converted
||View pointer to be used for the conversion
VECTOR* - screen coordinates converted to world positon.
Prior engine versions (A7 and earlier) used a more crude algorithm that didn't take into account the angle of the ray through the XY screen position to the screen center axis. This does not matter for coordinates on the screen, as the difference is less than one pixel, but it matters for coordinates that are far off the screen center. In that case, A8 gives more precise results.
mouse_mode = 4;
v.x = mouse_pos.x;
v.y = mouse_pos.y;
v.z = 200;
vec_to_screen► latest version online