Menu
CoddyTech

Camera Limits

Part of the Game Feel section of Coddy's Godot journey. Lesson 9 of 23.

The camera follows the robot past the edges of the level. At the start you can see the empty dark to the left and under the floor.

A Camera2D has four limits, in level pixels. The view never goes past them.

extends Camera2D

func _ready():
	limit_left = 0
	limit_right = 1600

A limit is an edge of the view, not of the camera's center. With limit_right = 1600, the right edge of the screen stops at 1600. The camera's center stops 320 pixels earlier. limit_top and limit_bottom work the same way up and down.

challenge icon

Challenge

Easy

This script is on the camera. In _ready, keep the view inside the level: limit_left 0, limit_top 0, limit_right 1600, limit_bottom 360.

Try it yourself

extends Camera2D

func _ready():
	pass
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Game Feel

Practice on your own: Godot playground