+1 vote

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)

asked Apr 16 in Engine by Godot_Starter (260 points)

1 Answer

+4 votes
Best answer

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.

answered Apr 16 by caprinae (264 points)
selected Apr 16 by Godot_Starter
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.