Screen To World: Difference between revisions
-u ndefined- (talk | contribs) m (Add infobox, minor rewording and Related section) |
(Small improvements) |
||
Line 9: | Line 9: | ||
}} | }} | ||
Given a screen coordinate, outputs the start and end points of a line going through that point (2 and 400 units away from the camera, respectively). That might sound weird, but usually you'll just wire those points into a [[Raycast]] to find the object the user tapped! | Given a screen coordinate, outputs the start and end points of a line going through that point (2 and 400 units away from the camera, respectively). | ||
That might sound weird, but usually you'll just wire those points into a [[Raycast]] to find the object the user tapped, or [[Line vs Plane]] to find where on the ground the user tapped! | |||
== Notes == | == Notes == | ||
Line 20: | Line 22: | ||
* [[World To Screen]] | * [[World To Screen]] | ||
* [[Screen Size]] | |||
[[Category:Blocks]] | [[Category:Blocks]] |
Revision as of 12:48, 27 May 2024
Screen To World
Type | Script block |
Collider | None |
Folder | Math |
Ports | |
---|---|
Inputs | Screen X Screen Y |
Outputs | World Near World Far |
Given a screen coordinate, outputs the start and end points of a line going through that point (2 and 400 units away from the camera, respectively).
That might sound weird, but usually you'll just wire those points into a Raycast to find the object the user tapped, or Line vs Plane to find where on the ground the user tapped!
Notes
Due to a technical issue, still to be fixed, the output lags by one frame. In other words, if you Set Camera on frame N, then this block's output will change on frame N+1.
Because of this bug, the script will not function correctly on the first frame. To avoid incorrect values, use the block's output only if the Current Frame is greater than 0.