+2 votes

I have a KinematicBody2D node with a Camera2D child. When I press a button, I want the camera to smoothly pan over to another node.

I thought I could achieve this by simply swapping which node the camera was a child of. For example, in my Camera2D script, I have:

func change_focus(node):
    get_parent().remove_child(self)
    node.add_child(self)

Unfortunately, this cause a discrete camera jump to the new node. I want the camera to smoothly pan to the new node from the old one.

How do I get the camera to smoothly pan to the new node?

I tried altering my function by manually setting the global_position of the camera to the global_position of the old node, hoping that, because smoothing is enabled, it would pan to the new node, but it didn't work.

asked Jun 10 in Engine by Diet Estus (1,305 points)

Please log in or register to answer this question.

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.