Menu
CoddyTech

A Smooth Camera

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

A camera fixed to the player starts and stops with sudden jerks. A camera that trails a little behind and then catches up moves more softly.

Camera2D does this with position smoothing.

position_smoothing_enabled = true
position_smoothing_speed = 4.0

The first line turns smoothing on. The speed sets how fast the view catches up. A small number trails far behind, and a big one hardly trails. Godot's default is 5.

The camera node still moves with the player. Only the view on screen lags behind.

challenge icon

Challenge

Easy

Make the camera catch up smoothly.

  1. In _ready(), set position_smoothing_enabled to true.
  2. Set position_smoothing_speed to 4.0, and keep the limits.

Press Play and run: the view trails behind, then catches up. Then Check.

Try it yourself

extends Camera2D

func _ready():
	limit_left = 0
	limit_top = 0
	limit_right = 1600
	limit_bottom = 360

All lessons in Game Feel

Practice on your own: Godot playground