It would be nice to have the extended syntax of the screenToWorld scripting command from VBS.
Alternative syntax allows the determination of any position on the screen, by defining its distance from the camera:
screenToWorld [X, Y, distance]
Params:
- X: Number - X-coordinate of 2D screen position.
- Y: Number - Y-coordinate of 2D screen position.
- distance: Number - Distance from the camera, extended in the direction the camera is looking.
Returns end-position of a virtual line with the specified length (distance), starting at the camera, and ending at the defined screen position. Any ground or objects in the path are ignored.
Sample:
_mouse = getMousePosition; _pos = screenToWorld [_mouse # 0, _mouse # 1, 10]; someObj setPosAGL _pos; //Setting the position of someObj 10 m in front of the player relative to the mouse position