Get screen space to world returns slightly offset values.

I’m trying to get a screen mouse clicks to go to a world position (depth 0, hence the mult direction by 1000) but it doesn’t work with a perspective camera, ortho is perfect. Can anyone share what I’m doing wrong? I get a slight offset from the position and the further away from the screen middle point I click the larger the offset is… Don’t exactly want to add a multiplier to offset the position as that’d just be too hacky for my liking…

Thanks!

In case anybody would be inclined to look into this, I think I know why this happened (not at my computer right now) - I have a large poly below my pawn and other sprites which is what will return the line trace hit. It’s a few units below all the other polys and since my pawn is above this Z value (which is also essentially the depth axis from camera view) it won’t match up. Seems logical but I’ll test it as soon as I can.

Dont know if it works with touch Input (sounds more like a mobile Input). I always use the mouse left/right event. to get the mouse Position you can use Playercontroller->getmouseposition (or location ?).
Just in case you Need it you can Show the curser by set “Show Cursor” in your PlayerController. And maybe use 10k or even 100k just to be sure :slight_smile:

I’ve set use ‘use mouse for touch’ (or similarly worded) to True somewhere in the project settings which stops you from having to add both mouse and touch input if you’re dev-ing for both. I think I tried the playerController route actually but had some problems with it… can’t remember what so now I’m curious again haha. Thanks for the input!

Searches through screenshots

I believe you need something like this. :wink: The problem is that when you convert a screen space into world space when dealing with a perspective camera it does so in a sphere with the camera at the middle. The “Get Distance To” is used to find the distance I wanted something be away from the camera. You can change this to what ever you want your distance to be. Just copy everything from the “World Location” & “World Direction”.

I however can’t remember if this only worked in 1 axis but the sine node is used to offset the distance to compensate for the spherical nature of the conversion keeping the location on the same plane.

Ok, that is pretty awesome. I’m not quite sure how that works but it does. Thank you so much for explaining the issue and the solution!!

In that path, the get distance to is between the controller and the camera? Is that what the Sequence Owner is? And why do you subtract it by 16?

Thanks in advance :slight_smile:

Edit: Trying to combine your logic with the Get Hit Result Under Finger by Channel, I’m having the exact same problem as above… my “distance” from my player pawn isn’t universal because of the camera distortion. The Get Hit Result doesn’t have a Direction Node… winging it here.