Get camera position: Difference between revisions

From Fancade Wiki
(Added to a category)
(Fixed broken link)
 
Line 1: Line 1:
Unfortunately, there is no built-in "Get Camera" block.
Unfortunately, there is no built-in "Get Camera" block.
The easiest way to get around that is to save the camera's parameters in [[global variables|Variable#Global variables]] while (or instead of) setting them with Set Camera, then reading from them when needed.
The easiest way to get around that is to save the camera's parameters in [[Variables#Global variables|global variables]] while (or instead of) setting them with Set Camera, then reading from them when needed.


If that's not an option for you (for example, if you're making a custom block for <i>everyone</i> to use), it <i>is</i> possible to calculate the camera's parameters with [[Screen To World]] and some clever math.
If that's not an option for you (for example, if you're making a custom block for <i>everyone</i> to use), it <i>is</i> possible to calculate the camera's parameters with [[Screen To World]] and some clever math.

Latest revision as of 21:26, 4 July 2024

Unfortunately, there is no built-in "Get Camera" block. The easiest way to get around that is to save the camera's parameters in global variables while (or instead of) setting them with Set Camera, then reading from them when needed.

If that's not an option for you (for example, if you're making a custom block for everyone to use), it is possible to calculate the camera's parameters with Screen To World and some clever math. However, this will lag behind the real camera by one frame, as Screen to World uses the current frame's camera, while Set Camera affects the next frame. If that's not a problem for you, here's an example by Mathias Elgaard. (Or try to figure it out yourself, it's fun!)