+1 vote

Hello guys,

following hierachy:
CanvasLayer (with script), child is a Node2D with Camera2D as its child. The camera is set to current but does not follow the Node2D which position is manipulated in teh script. All other Camera2D setting are default.
Additional Info: Pressing play not even centers the camera on the Node2D object.
PS: I would like to insert a screenshot but somehow this is not possible.

Godot version v3.4.2
in Engine by (35 points)
edited by

look

https://godottutorials.pro/how-to-make-games-godot/

/////////
Add to "image"
example: google drive

Thank you, but this doesn't really help.
Even if it shouldn' be nessecary to do this; i added this to my script:

onready var cam = $Camera2D
onready var cursor = $Cursor
func _process(delta):
cam.position.y = cursor.position.y

but it did not change anything.

your code is working. Is there something in the background?

here is everything:
https://ibb.co/QYV3KgT
i do not understand why the camera is not following the cursor.

You are quite right. I think there is a place we missed.

You don't even need it like you said.
func _process(delta):
cam.position.y = cursor.position.y

1 Answer

0 votes
Best answer

The root node here must not be a CanvasLayer, it has no transform. Changing it to Control solved it for me.

by (35 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 Frequently asked questions and 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 [email protected] with your username.