Havin a camera2d centered on a player/sprite

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Syl

Ho to do that please, instead of an out the screen trackin?

:bust_in_silhouette: Reply From: BraindeadBZH

Just place your camera as a child of the player’s node.

What I’ve done, but is there a fonction to increase the range of camera trackin, so that it doesn’t start when enterin the screen limit, but a bit before? So that my player still have a far view ahead.

Syl | 2018-03-27 22:22

:bust_in_silhouette: Reply From: Bartosz

You need to set camera as player child then use cameras drag_margins to make it follow Player e.g drag_margin_left Docs are rather helpful:

float drag_margin_left - Left margin needed to drag the camera. A value of 1 makes the camera move only when reaching the edge of the screen.

Cheers again Bartosz! Exactly that! Thxs you both. :slight_smile:

Syl | 2018-03-27 22:41