I can't get the camera to follow my player in my 2d game. How can I fix this.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PartyChat

Before you comment with the obvious answers and solutions, don’t. I have tried everything you were probably going to tell me. I’ve made the Camera2d node the child of my player, i made it the current camera by using the properties tab, i even tried coding it in. Messed with every setting there is, looked up every way i could, reinstalled Godot. It WILL make it the current camera but it doesn’t fall like my character, it wont move with it, I enabled it so the children of the character couldn’t be selected. No matter what i try, it refuses to move with the character. Someone please help.

Before you comment with the obvious answers and solutions, don’t. I have tried everything you were probably going to tell me.

Sorry but I’m just gonna read what you wrote and just ask potential stuff which you did not explicitely describe (I don’t read minds).

I’ve made the Camera2d node the child of my player, i made it the current camera by using the properties tab

So that should basically make it follow your character. If you move the parent of the camera (i.e the character) and drag margin is off, camera is current and all others are not, then the camera should follow it. Of course if you use smoothing it should have a non-zero speed.

Unfortunately this is the only hint I can think of, you will have to post your scene layout and code (perhaps just your project) because we can’t help you without more details.

Zylann | 2020-09-17 12:34

what kind of object is your player? (kinematic, rigid body, etc.)

Millard | 2020-09-17 15:03

Kinematic Body.

PartyChat | 2020-09-17 19:58

I tried turning drag margin on and off, it does nothing. I have tried making new cameras, new players entirely. The weird thing is it works in 3d just fine, but 2d refuses to work. I’m starting to assume it might be a glitch, because if i select my character, and move it around, the camera will move around with it, but if i try to play the scene, the character will move but the camera wont follow it.

PartyChat | 2020-09-17 20:04

sure sounds like a glitch. Could you post your players code? Does the camera have a script attached to it?

Millard | 2020-09-17 20:42

Code or posting a repo would help us solve it real fast… Until then, are you using ANY CanvasLayers anywhere in the scene? CanvasLayer is stupid quite often and you don’t usually need them. Same question for viewports.

MonsterVial | 2020-09-18 12:41

my scene only has the character, which is its own individual scene which i implemented into the main scene, the camera as a child of it, and a tilemap. I have the character arranged in front of the tilemap so it appears in front of it.

PartyChat | 2020-09-18 16:49

:bust_in_silhouette: Reply From: PartyChat

I’m incredibly confused as to what just happened, thank you all to whoever tried to help, but the camera has all of a sudden started working somehow, i haven’t edited any settings whatsoever, yet no it works just as I wanted. I’m going to chalk this up to a glitch.

glad it’s working! It’s crazy how stuff can start working all of a sudden. Usually when you are trying to show someone the problem. lol. :slight_smile:

Millard | 2020-09-18 18:07

BTW, good luck with your game. :slight_smile:

Millard | 2020-09-18 18:08