Im making a simple platform game and want to make the "camera2d" follow the player. When i add the camera, my code for movment stops working, but when i delete the camera, everything is ok. What can i do to fix that??

    this is my code for my camera

    extends Camera2D
    onready var player = get_tree().get_nodes_in_group("player")[0]
    func _ready():
    	set_physics_process(true)
    func _process(delta):
    	global_position.x = player.global_position.x
    	global_position.y = player.global_position.y

    Megalomaniak The player code doesn't matter, basically what I did is add to the camera code a variable that is equal to the player (telling it that it is equal to the player group node "get_tree().get_nodes_in_group("player)[0]") and in the delta process of the camera I tell it that its global position is the same as in the variable that is equivalent to player, always remember to activate the current option in the camera that you want it to be used (sorry for some error in the syntax of this message I'm using google translator)

    Draberos12345 my code for movement stops working

    How do you know that it is not working?

    If the player is moving, and the camera is moving with the player, then from the camera's point of view, the player will not be moving.

    Also, an easier way to make the camera move with the player is to make a camera a child of the player. Then no camera code is needed to move it.