Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Get Screen Location to World Space

Can anyone tell me exactly how the 'Get Screen Location to World Space' node works?

Been messing around with it and I can't seem to get any coherent values out from the world location output pin. No matter what numbers I put into the Screen X and Screen Y input pins, it always returns 10.

I presumed that if I put an X value between 0 and the max pixel size, it would return me that value in world coordinates, that doesn't seem to be the case.


alt text

Product Version: Not Selected
untitled.png (26.6 kB)
more ▼

asked Jun 12 '14 at 09:50 PM in Blueprint Scripting

avatar image

101 15 16 22

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hey Glenn1990,

What kind of setup are you using to get/print out your World Location?

If you think of it in terms of using a mouse to click a location on the screen or using your finger to touch a screen, a 2D location is returned, which could be passed into your Screen X and Screen Y. This function then converts that XY pair into a 3D World Location, which you can use as your starting location for a Line Trace, and a World Direction, which you would use with a magnitude (basically, a multiplier) to figure out how far you want to draw your line trace to see what you would hit under that screen location.

Hope that helps--let us know if need any more information about this particular functionality.


more ▼

answered Jun 12 '14 at 10:54 PM

avatar image

Steve Allison STAFF
4.3k 123 58 209

avatar image KamiUE Dec 02 '14 at 03:07 PM

hey steve and thanks for your guide but can u explain a little more about this function??how does it convert a screen location to world space location?whats the criterion?? thanks in regard :)

avatar image Slayemin Jan 05 '15 at 07:36 PM

It doesn't really matter how its done, so long as the result is correct, right?

For what its worth though, here is how it's done:

What we're trying to do is draw an intersection ray into the game world. To do this, they figure out where on the screen you clicked. This maps to a coordinate on the current cameras near plane. You can then draw a ray from the camera position to the near plane coordinate. This gives you the direction vector for your ray. They also know the near plane position (because its included with the camera as a part of its view frustum), so deriving the ray position is really easy as well: you just do a linear interpolation on the near planes topleft corner to the bottom left corner with the same amount as the click position is from the top left corner from the viewport window. Now we have a ray which has both a direction and a position. So, what next? We shoot it out into the world and see what objects we intersect with. Usually, this will return everything the ray intersects with, and that's not necessarily useful (ie, clicking on an actor shouldn't give you the terrain). The UE4 team gives you a choice to filter out results using "trace channels". This makes things a teeny bit faster. You are also given the option to limit the length of your ray, so if you know beforehand that the object you're trying to reach is within 100 units, there's no need to shoot out a ray with a length of 100000 which will return 100 results. The ray trace channel will usually return the nearest object it intersects with on the ray. So, if you accidentally have objects in front of the object you're trying to click on, you'll get those objects instead of the object you want. Watch out for this.

Still curious on how exactly does UE4 do it? The best way to learn that is by just downloading the engine source code and looking at their line trace code. Alternatively, you can google "Mouse Picking" to see how its done generally.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
more ▼

answered Jan 09 '18 at 05:14 PM

avatar image

6 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question