Camera 2d follows only the x-axis

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

Is there a way how a childnode of a kinematicbody2d only follows the x-axis if the kinematic body 2d moves, so if the kinematicbody2d moves up the childnode dont moves up, to.

(I want to use it for a Camera2d, but it will be great, if it works for node2d, to)

:bust_in_silhouette: Reply From: caprinae

Instead of assigning the Camera2D as a child, you could do this in a script. On every frame simply set camera.position.x = body.position.x. This way your camera would follow the body on the X axis, but not on the Y axis.

This would work for any node, not just a camera.