godot

How to make camera follow player in Godot


I'm making a top down game in Godot, when I add the Camera 2D node to my player and set it to current, the player is stuck in the same place and can no longer move. I get this error message

modules/gdscript/gdscript_tokenizer.cpp:1129 - Condition "tk_rb[ofs].type != TK_IDENTIFIER" is true. Returned: StringName()

Is there any way to fix this, or am I not providing enough information?


Solution

  • Make sure that the Camera 2D node is a child of the player and the camera has no scripts. just check the current check box in properties and it will work.

    enter image description here