• 2D
  • camera position limits

im making a city builder, there is not a 'player' with a camera, the camera is a scene with functions

ive tried all day set the camera2d limits position, search in the forums, looking for solutions, different ways, but nothing works for me when zooming the camera or moving past the limits

some like this does not work

if position > limit_left:
	position = limit_left

it just keep moving for some reason past the limit

I even tried adding several types of bodys and collisions to it, but it does not matter, with the zoom nothing works :( i didnt found precise info on the net either Has anyone already been on this train? I mean camera vs position vs zoom??

so, since I have no patience for these things and I don't want to waste time with such a simple thing (imo), I have added 4 visibility notifiers on each side of the stage as borders. When one of them 'is visible' on the screen, it blocks the _input to that side and the camera doesn't move that way either, therefore it does not go beyond that border, no matter the zoom

It seems that it works perfectly.... but what do you think?

If it works, then I'd say it seems to be a fine solution :+1: I don't see any downsides right away, other than it requires your level boundaries to be rectangular, but that would be the case with the camera limits too.

Haha I like it! Seems like a creative solution that might work out better than a logical one. If it were me I think I'd child the camera to an invisible dot that can move around on the 2d game map. Then you could bound that object the same way you do to other game objects.

ok the problem here is when you zoom in the camera in a corner-screen, the camera center goes there, ok

but when you zoom out, the camera center continues 'there' and there is a little 'movement delay' trying to recover the actual real center, not sure if im explain myself good

i fixed this reseting the center when zooming out

if event.button_index == BUTTON_WHEEL_UP:
	zoomfactor -= 0.01 * zoomspeed
if event.button_index == BUTTON_WHEEL_DOWN:
	zoomfactor += 0.01 * zoomspeed
	position = get_camera_screen_center() # magic