Hey there,
I installed renderecam for fixed aspect ratio. I can manipulate the position of the camera but i don’t know how to manipulate the properties like zoom, fov.
Please help me
Hey there,
I installed renderecam for fixed aspect ratio. I can manipulate the position of the camera but i don’t know how to manipulate the properties like zoom, fov.
Please help me
In the readme you can scroll down to Camera functions. Says in a script you require the render cam module local rendercam = require "rendercam.rendercam" then you can use the camera api provided for zoom , fov etc.
yes i did “rendercam.set_ortho_scale(100,“camera”)
rendercam.zoom(5, “camera”)” and it zooms nothing i also tried rendercam.zoom(5, “camera”) as itself and that did nothing too
The script with the api may need to be executed after the rendercam initializes. So in the script you can use a timer to make sure its executed later example:
local rendercam = require "rendercam.rendercam"
function init(self)
timer.delay(0.01, false, function()
rendercam.set_ortho_scale(3.0)
end)
end
It has been a while that I’ve used Rendercam, so I had a look.
If you have one camera only, you do not need it as an argument.
This does not zoom in by 100 as you probably expected, it zooms out. And not by 100, but by 100x100, a massive amount.
Again, this zooms out and not by 5. The value is multiplied by a small factor (0.01) and then added to the current orthographic scale. So you’d add 0.05 to it - too small to be noticable.
Check out Rendercam’s ReadMe and the example project Rendercam provides. I’d play around with the values in the camera’s properties and add a couple of print statements to see what is going on.
As for most of the other properties, like fov, Rendercam does not provide functions to set them at runtime.
You’d have to add this functionality yourself . Either by adding functions to rendercam.lua (check out M.set_ortho_scale(s, cam_id) in rendercam.lua to give you an idea). Or by passing messages to the camera.script. For this check out: Message passing in Defold.
Note that those new values will not show up in the editor, so don’t be puzzled by it.
thank you this worked but this only zooms out and i also want to zoom in
In this case you will want to use rendercam.zoom(amount) the amount can be positive or negative, positive amount will zoom out while negative number will zoom in. There will be limits in how large the numbers can be I would stay within 100 or so or you may get errors.
Example:
//zoom in with negative value
rendercam.zoom(-20)
Thank you, this worked.
One more thing is there any way to set the zoom value and not just add and subtract from it?