Defold Orthographic - The Orthographic Camera API

@britzl How to use this library when there are a few states (menu and game screens for example) ?
for example, how to implement this lib in this your example of MenuAndGame

I added camera.go to controller.collection

from game.script I call:“controller:/camera#script”, “follow”, { target = self.followMe })

and got the error:

/orthographic/camera.lua:203: Instance (null) not found


I would use multiple cameras and enable/disable them as I switch screens.

This seems to indicate that self.followMe is nil. Perhaps the object you’re supposed to follow has been deleted?

BTW I’ve released a new version (1.4.2) of the library that adds argument asserts on all public facing functions to warn when this happens.


no, when I add the camera to game.collection. there are no errors.
but okay, I can try to use each camera for each screen collections.

EDIT: yes. I like the solution with where each state has own camera. Thanks!

1 Like

@britzl any idea how to add the follow_point(x,y) function?

go.set_position(vmath.vector3(x,y,0), “camera id”) should be enough. The camera centers the view on its position.

1 Like


How should I proceed to add black bars to orthographic? Going for a specific look and don’t want to show more of the game screen than necessary when aspect ratio changes :slight_smile:

You can either tinker in render script to adjust your window size (e.g. Subtract some value out of height and add offset on the bottom or use fixed values as you probably want), see, section manual integration and update function or… just add 2 simple box nodes in your gui that will cover those parts of the screen? :grin: Depending on what you need :wink:


I’ve released a new version of Orthographic. The new version supports a custom viewport per camera. This makes it very easy to setup and use multiple cameras, for instance when doing split-screen multiplayer. The new version introduced some breaking changes:

  • BREAKING CHANGE: Removed orthographic/render/helper.lua
  • BREAKING CHANGE: Removed Offset GUI option. Shake+recoil offset can still be retrieved using get_offset().
  • NEW: Camera viewport settings
  • NEW: Camera render order setting (lower value first)
  • NEW: Camera list using get_cameras()

Learn more: GitHub - britzl/defold-orthographic: Orthographic camera functionality for the Defold game engine


Noob question alert…

  1. Add camera.go to your game.

After adding dependency I can see camera.go in orthographic folder, but how add it to my game?
From tutorials I know that to add Game Object I have to use Factory. Do I need Factory in this case too?

For me as a guy who just passed all tutorial projects - add Game Object to your game is not clear instruction… Who can write step by step solution for me based on Walking astronaut tutorial project? Thanks!

P.S. I’ve added render as stated below, but I see black screen after building any of tutorial projects.

  1. Open game.project and make sure to reference orthographic/render/orthographic.render in the Render field in the Bootstrap section.

check this example:

1 Like

Open a collection file and right click in the outline (top right editor panel) and select Add Gameobject File.

1 Like

@britzl @BunBunBun Thanks guys! Digging into it :slight_smile: