How to use the Orthographic camera API?

Hello.

I did follow the installation steps as instructed at https://www.defold.com/community/projects/76573/ but still not making camera operation:
First, I added dependencies under game.project field and fetch the file library.
Next, I added camera.go from othographic folder to another game object (named: controller):

Then, I changed the default render script with /orthographic/render/orthographic.render at bootstrap in game.project

In the script file I write the following code:

local camera = require “orthographic.camera”
print (camera.get_zoom ("/ camera"))

Debug produces results:

ERROR: SCRIPT: /orthographic/camera.lua:506: attempt to index a nil value
stack traceback:
/orthographic/camera.lua:506: in function ‘get_zoom’
/main/controller/controller.script:11: in function </main/controller/controller.script:7>

What should I do now?
Thank you.

Two things:

  1. Call the camera functions from the lifecycle functions, such as init, update, on_message, on_input etc

  2. The camera id should be a hash. Try:

    print (camera.get_zoom (hash("/camera")))

1 Like