3
\$\begingroup\$

I am working on a small game in Unreal Engine 4.15 using blueprints only and encountered a behaviour I don't understand.

The game is based on the Top Down Example. As I'd like to teleport an actor to a world location corresponding to a screen location (i.e. left edge of the viewport). I use "Deproject Screen To World". Giving screen X = 0 and screen Y = 0 as input to this node, outputs world coordinates close to the bottom center of the viewport. In order to get a test actor to move to outputted world coordinates close to the left edge of the viewport, input screen coordinates need to unexpectedly high (around -20000.00 for both x and y). This occurs strange to me, as the viewport is much smaller (around 1400x740 in editor preview).

I was hoping to use something like -(viewport width/2) for x screen coord (in case the x origin is centered.

Where is the origin for screen coordinates?
What unit are they measured in?

Note: The location on screen is not set from mouse position, so i can not use "Get Hit Result Under Cursor".

\$\endgroup\$
0
\$\begingroup\$

Origin screen coord in Unreal 4.21 are x=0.5, y=0.5. The coords you are giving (0,0) are the bottom left of the screen. The scale is based on a 1:1 scale, so that all screens regardless of number of pixels, shape, or size can display the crosshair (or other output) in the same "relative" location. So if you wanted a health bar at the bottom left of the screen you could code something like this "x=0.025, y=0.025" and it would be in the same relative bottom left corner of every screen (i.e. iPhone, PC, tablet, landscape mode, portrait mode, etc...

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.