+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)

in Engine by (330 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.

by (266 points)
selected by
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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.