0 votes

I'm making a game where the camera needs a sprite to follow it on the x axis, so that it always shows on screen. I have a KinematicBody2D for the player, and a Camera2D node as a child of the player, the main problem is that I can't make the sprite follow the smoothing of the camera. I tried a lot of things already, including making the camera a scene, making the sprite it's own scene, adding scripts to both the camera and the sprite, but nothing seems to work. I'm relatively new to godot so I don't get a lot of how these nodes, scenes and other things work, so I'd like a bit of help.

in Engine by (17 points)

2 Answers

0 votes
Best answer

Add a CanvasLayer-node as a child of your Camera2D and make the Sprite a child of this CanvasLayer-node, then set the position-property of the Sprite as you'd like.

by (10,255 points)
selected by
0 votes

There's no need to make the camera or sprite an instanced scene. If both the Sprite and Camera2D are children of the KinematicBody2D, use moveandslide to move the KinematicBody2D node. The smoothing in the Camera2D node will interpolate in global space.

by (3,201 points)
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.