I finally got sick of rewriting render scripts, camera functions, and screen-to-world transform code over and over again (and hearing of other people doing the same), so I’ve put together a library to handle all the basic camera types that I could think of and most of the common camera-related functions. It’s similar to Defold Orthographic, only it supports perspective cameras too.
Rendercam gives you a simple render script, a camera game object, and a controlling lua module. Together they support:
- Perspective and Orthographic cameras
- Fixed aspect ratio viewports (or not)
- Setting a specific world-space view area
- Four options for how the view changes for different resolutions and window sizes
- Switching between multiple cameras
- Lerped camera following
- Screen-to-world transforms
- Screen-to-world-ray transform for full 3D games
- World-to-screen transform, with an option for each GUI adjust mode
It’s very simple to use, just install the library (dependency link), hook up the render script, and add the camera game object. All the camera settings are just properties on the camera’s script component. See the github page for full documentation.
At this time I’ve only just “finished” the library. Consider it a beta. I think I’ve tried all the features with my small test project (which you can grab from github if you want), and everything seems to work, but it hasn’t been through a “real world” test yet. So, if you feel like trying it out, let me know what you think! I’m sure there are things that need improving. I plan to do some small trial projects with it myself, but I would really appreciate some outside feedback. Thanks!