Hello, I am in the middle of making jump king like game. I want to create the same camera movement like in the Jump King, but I have a little problem here. In this scenario the first level is 0 pixels, but when the player reaches it, the camera moves strange, idk how to explain, but the camera moves weirdly upper, but when the player fall down the camera doesnt go down. Here is my code so far, my resolution of the game is 800x600 if it help. Thanks for any help. <3

@export var camera_height: int = 600
@export var camera_limit_lower: int = 600
@export var camera_limit_upper: int = 0

func move_camera_to_match_player():
if position.y < camera_limit_upper:
camera_limit_lower -= camera_height
camera_limit_upper -= camera_height
change_camera_pos.emit(camera_limit_upper)
if position.y > camera_limit_lower:
camera_limit_lower += camera_height
camera_limit_upper += camera_height
change_camera_pos.emit(camera_limit_upper)

    vojunko

    @export var camera_height: int = 600
    @export var camera_limit_lower: int = 600
    @export var camera_limit_upper: int = 0
    
    func move_camera_to_match_player():
    	if position.y < camera_limit_upper:
    		camera_limit_lower -= camera_height
    		camera_limit_upper -= camera_height
    		change_camera_pos.emit(camera_limit_upper)
    	if position.y > camera_limit_lower:
    		camera_limit_lower += camera_height
    		camera_limit_upper += camera_height
    		change_camera_pos.emit(camera_limit_upper)

    why? are you doing this?
    you can just lerp to the player position
    camera.global_position.y = lerp(camera.global_position.y, player.global_position.y + camera_shift, 0.5)

    and if what you want is for the camera to move up after reaching the top, maybe use the camera2D drag? it's in the inspector.

      5 days later

      vojunko in the camera, in the inspector, there are drag options to make the player drag the camera when near the defined edge.