How camera works?

I create a gameObject with a camera and script inside, in the script I put

msg.post("#camera", "acquire_camera_focus")

but nothing happens. Any good tutorials? thanks

1 Like

There’s the Camera manual: https://www.defold.com/manuals/camera/

When a camera component has focus it will send view projection messages to your render script. Are you using a custom render script?

You could also look into one of the camera extensions (RenderCam and Orthographic).

2 Likes

I think the camera manual needs to be more helpfull…

Im using the standart render. I want to set the height and width of the camera, but changing propierties seems to not work.

There’s no height and width properties for the camera. The default render script uses an orthogonal projection matrix and the camera component will feed it a projection to use (ie near and far z and what part of your game world to center on). If you want to change the scale (ie zoom in/out) then you need to change your render script and change from the default stretch projection to the zoom projection.

1 Like

You can also look into using a community library for setting up cameras:

3 Likes

I tried chaging some things in render script but cant get it work. could you tell me , what I need to do? (changing the zoom )thanks

Ok, to use your own render script you start by copying the default.render_script from builtins/render/ to some location in your project. Next step is to create a render file and point it to your copy of the render script. Last step is to open game.project and change from using Bolton’s/render/default.render to the render file you just created.

With these steps done you have your own render script that you can modify as much as you like. Open your render script and change the call to stretch_projection to fixed_fit_projection and pass in the correct arguments.

In the next release we will make this process slightly easier.

1 Like

This is documented here btw: https://www.defold.com/manuals/render/#_the_default_render

Also maybe this will help

5 Likes

ok, I did that, look for strech_projection and change it for render.set_projection(fixed_fit_projection(-1, 100)), but renders in the same way.

Ok, hours later, and changing random functions, I discover how to zoom in/out…

now, how to render only 800x600 window, for example, and render the same with diferent screen resolutions?

offtopic: I want to use defold engine for my studies end project, but its extremely difficult to do the most basic things.
I did things with unity, godot, love2d, and no one has this level of undocumented /lack of tutorials. If you look in the internet , there isnt info of defold, and not many people are using it, and I dont think this is because of a bad engine, I think is for the
impossibility of learn this great engine. If the priorities of the team were to document all, create tutorials for newbies or extended tutorials and teach your engine, sure that this will be top tier engines. why create more features or fix bugs if nobody knows how your engine works? . In the end, the engine succesfull is made by his users.

and the defold team are very helpfull and kind, to be honest, you only need to explain your engine (10 years old like tutorials, step by step tutorials) and the people will come fast. :slight_smile:

Yes, it renders the same way to start with, but if you resize the window and change the aspect ratio you will see a difference:

43
51
11

The stretch projection will as you see keep the same area of your game visible regardless of how you resize your window. The drawback is that when the aspect ratio changes it will also stretch your content.

When you switch to fixed_fit_projection the aspect ratio of the original will be respected and more content will be shown.

Not sure what you mean by changing random functions… If you switch to fixed_projection you can also set a zoom (while maintaining aspect ratio):

-- zoom to 50% of original size
render.set_projection(fixed_projection(-1, 1, 0.5))

26

Well, if you set 800x600 in game.project and use fixed_fit_projection you will guarantee that the original area of 800x600 will be shown, zoomed in or out, depending on window size. What you need to consider is how to deal with a window size with an aspect ratio different from 800x600. Is it ok to show more of the game outside of that area? Or should it be black? Or show some kind of border?

It is my belief that our documentation is pretty good. We usually get praise from our users for the documentation. But, apparently not everyone feels the same. Could you please point out a few more areas where you have absolutely no clue how to solve a problem using Defold but where it is easy to do in Love2d or Godot? I’d be happy to look into those areas and see if we can improve the documentation. Thanks.

5 Likes

I want the game go in full screen, but always render the same size, regardless of the screen / resolution that the computer has.

I continue without knowing how to do something as basic as controlling what is rendered and maintaining the ratio of the screen. Really, if you think that the documentation is perfect, then I dont say any more…,
in the documentation of the rendering,doesnt explain how to do this, or how to make multiple screens, or how to do the zoom, (a simple tutorial explaining that in X line, you have to change the function by render.set_projection (fixed_projection (-1, 1, 0.5)) and adding that the zoom value when it is lower, the less zoom it has, it would be a good start.)

godot1

this is how choose the mode rendering

godot2

and select aspect ratio to keep. no doubs , no question in forum.

I do not say it to bad, and I move from arguing. Why do you think so few people use defold? If someone finds it interesting, as is my case, but it is impossible to do anything, what will it do?

I take days to solve this, and what I have left. Greetings.

There is a Fullscreen checkbox in game.project. That checkbox combined with fixed_projection will do exactly this.

You mean as in menu screen, start screen, inventory screen etc? If you read the documentation it becomes quite clear that Defold provides many low-level building blocks that can be used to implement high-level concepts such as screens, popups and transitions. We do not provide any of that out of the box. If you need a screen manager then take a look at Monarch in our asset portal. It creates the concept of screens and transitions from the low-level building blocks that Defold provides.

We have a task to improve the render script documentation in our next sprint (starting on Monday). Expect updated docs in this department during the coming two weeks.

Yes, that looks nice! I’m not saying that we can’t do better in that respect in Defold, but one thing that makes it harder for us is that Defold operates on a lower level in this case. The render script is a fully scriptable rendering pipeline that allows you to have full control of all aspects of how your game is rendered, all of it done using Lua.

I’m sorry to hear that you were stuck for days. The next time you’re in doubt please ask here or on Slack. You usually get an answer within an hour or two, sometimes in just a few minutes if you ask during office hours.

4 Likes

One of the problems is my bad explanation with english, I made a picture showing what I try to explain this days.

explain

top left is the standart, amd below is what I want, changin zoom, diferente resolutions, but mantain the information shown. at the right its what defold is doing, showing me more elements depending of the resolution of the device. without streeching the sprites

I may be a little late, but I found this tutorial extremely informative and easy to follow. Step-by-step instructions for using the RenderCam extension to leverage Defold’s native 3D for layering foreground, background, player, etc. Highly recommend giving it a quick read, if not following it exactly.

5 Likes

Woah, nice set of tutorials! Thank you for sharing!

thanks

I switched from Godot to Defold too, a while ago. Rendercam was kind of designed to make doing this stuff with Defold about as easy as it is with Godot—just a few checkboxes and things. Britzl’s Orthographic is also a great solution. Defold is a bit “lower-level” than Godot, and assumes you know a bit about how 3D graphics work.

3 Likes

Sorry for off-topic, but may I ask you - why did you switched? What was “bad” in Godot and “good” in Defold?

2 Likes

ĂŤn my case its for using lua, and the easy of creating an exe file. in godot custom icons and some properties doesnt work.
and looking for a tool to stick with it. Looking for the right balance between full control of the libraries and the easy use of an engine. I try a lot of tools in many years, and now wants to try this, for lua, performance and learn different designs of making games, then I will choose the best engine or go down and check more frameworks or libraries (I only try love2d and like it, but one day I wish to go down and try a library (raylib for example))

3 Likes