SmoothCamera

Inherits: Camera2D < Node2D < CanvasItem < Node < Object

A Camera which moves smoothly with the target.

Warning: The Camera may appear buggy on high refresh rate displays due to a mismatch between physics and process frames.

Process Frames run at your display frequency but Physics Frame (by default) run at a fixed 60Hz

Consider turning Physics Interpolation ON in the project settings or try manually alligning the two.

Properties

Node2D

target

float

smoothing

0.05

Vector2

offset_unit

Vector2

offset_value

Vector2(0, 0)

Methods

void

_ready()

void

_process(_delta: float)

void

set_target_offset(new_offset: Vector2)


Property Descriptions

Node2D target 🔗

The target which the camera will follow.


float smoothing = 0.05 🔗

Weightage for lerp().

Note: The most significant smoothing happens when this value is less than 0.1


Vector2 offset_unit 🔗

The distance between the camera center and the target in pixels when the offset_value is Vector2(1, 1)


Vector2 offset_value = Vector2(0, 0) 🔗

The value of offset. This is expected to be normalized but the code will still work if it is not. You can also use bigger vectors to offset the camera more than the offset_unit.

Final offset is calculated by `` offset = offset_unit * offset_value ``


Method Descriptions

void _ready() 🔗

There is currently no description for this method. Please help us by contributing one!


void _process(_delta: float) 🔗

There is currently no description for this method. Please help us by contributing one!


void set_target_offset(new_offset: Vector2) 🔗

Set value for the parameter offset_value