Discord
Login
Community
DARK THEME

I need help !!!

I need help with my camera. It doesn't look complicated; it looks like this.

initCamera = function()
  camera = object
    x = 0
    y = 0
    zoom = 1
  end
end

updateCamera = function()
  for p in liste_player
    if p.vie then
      if p.id == 1 then
        camera.x = p.x
        camera.y = p.y
        
        local zoomCible = 100 / p.taille
        if zoomCible < 0.2 then zoomCible = 0.2 end
        if zoomCible > 1.5 then zoomCible = 1.5 end
        
        camera.zoom += (zoomCible - camera.zoom) * 0.05
      end
    end
  end
end

The problem is with the zoom!

If you want to help me, let me know, and I'll send you a link. Thanks in advance.

Alright, I think I can help.

If you're wondering about how to actual zoom in, I found that screen.setScale(1/camera.zoom) is most effective. and I also noticed the little chunk,

if zoomCible < 0.2 then zoomCible = 0.2 end
if zoomCible > 1.5 then zoomCible = 1.5 end

which would be much more readable if you just used a clamp thing like,

zoomCible = min(max(0.2, zoomCible), 1.5)

If you're having trouble with actually setting the camera.zoom then a little more context would be great.

I send you a link think you

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community