My Camera3D Node will not stop jittering up and down

Godot Version

4.2.1.stable.mono

Question

Hey all! I am having a perplexing problem that I just cannot seem to fix. My camera seems to jitter up and down when the player moves slightly, I don’t know how to re-create it consistently, but I can sometimes by spamming the W and S key.

Okay! So I will tell you what I do know, and what I don’t know.

I localized the problem down to my Camera3D node that is the child of my Players CharacterBody3D node. Even though I never change the GlobalPosition on my Y-axis of my Camera3D OR CharacterBody3D the GlobalPosition on the Y-axis seems to jump up and down in very tiny increments (something like 0.001). It seems that sometimes these tiny increments will start to oscillate between eachother causing this jitter up and down.

I don’t know why my GlobalPosition changes on the Y-axis even slightly when I don’t move the camera on that axis, and I don’t know how to prevent that so I can prevent this jitter.

Video Examples:
Note: The first video has the GlobalPosition of the Camera3D in the top left, and you can see how the Y-axis changes ever so slightly when I move in the X and Z axes.

If the videos don’t load for you, let me know and I can put a different file formatted version of them in!

if you remove gravity is still will be happens? is look for me like player colliding with something

1 Like

Ah HAH! I think you’re right! The y-axis does not change when gravity is gone. Could it be because I am using a capsule shape for my CharacterBody3D ’s hitbox? And so the exact point of contact with the floor changes ever so slightly which makes gravity begin acting again (since body is no longer on the floor) causing the fluctuation in the y-axis? Do you know of anyway I could fix this problem.

Maybe add gravity when is not On Floor

		if (!IsOnFloor())

Thats the thing! I already had that, this was my gravity code:

// Add the gravity.
		if(!IsOnFloor()){
			velocity.Y -= gravity * 3.0f * (float) delta;
			stateDict["firstTouch"] = true;
		}

then check body, colliders and materials settings and try change things