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

Keep the view inside the level.

  1. This script is on the camera. In _ready(), set limit_left and limit_top to 0.
  2. Set limit_right to 1600 and limit_bottom to 360.

Press Play and walk to both ends: the view stops at the edges of the level. Then Check.

Try it yourself

extends Camera2D

func _ready():
	pass

All lessons in Game Feel

Practice on your own: Godot playground