Confusions about Orthographic camera

So I’m trying give Defold a try by porting an old plateformer I made in Monogame to it.

I’m now trying to make a camera, so I took a look at the documentation: It says

" For 2D games, it is often desirable to render the scene with an orthographic projection. This means that the view of the camera is no longer dictated by a view frustum, but by a box. " Perfect, this is exactly what I want.

So I make a Game Object and add a Camera to it. I check Orthographic Projection. Finally I set the Orthographic Zoom to 3 (my assets are rather small so I assume I will need to zoom in to see them properly).

Then in the doc it says: " To activate a camera and have it feed its view and projection matrices to the render script, you send the component an acquire_camera_focus message".

Ok, so I make a Script with init msg.post("#camera", “acquire_camera_focus”) and attach that script to the same Game Object.

This seems to be working because I see the game differently now than when it was the default camera and if I move the camera it reflects the change in the game.

So my issue now is that it seems like the Orthographic Zoom doesn’t do anything. If I set it to 1 or 1000, it’s the same screen. Is Orthographic Zoom something else than what someone would intuitivily think is a zoom?

I tried adding the line msg.post("@render:", “use_camera_projection”) to my camera script but it now shows a black screen even if I play around with the zoom level and position.

I got a response on Reddit.

Seems like I needed to set the Near Z and Far Z to -10 and 10.

I’m not really sure what these values do so I’ll go read about them, I was under the impression they weren’t used in Orthographic Projection, but it seems I was wrong.

The near and far Z define the “depth” of the box.

Yes, now I understand. So having both values in the positive made it so I couldn’t see my asset that were at Z = 0.

It makes sens now.

1 Like