Moving CharacterBody2Ds jitter in SubViewPort

Godot Version

4.2.1

Question

Hello! Sorry to be a bother.

I recently had to move my main game node into a subviewport (it’s Zelda-1 inspired, so the main game is in a subviewport vertically below the UI). I noticed that when I did this, my CharacterBody2D’s (enemies and the player) moved with a very jittery motion. They only do this when they are inside of the subviewport.

After some googling and testing, I found that I could fix this by flooring/ceiling the CharacterBody’s global position so that it would be an integer. HOWEVER, doing this makes it so that the CharacterBody has a very high speed that cannot be lowered. I have recreated this in a blank test project and it works fine, so I don’t know what I’ve missed. I should also note that I do have “Snap 2D Transforms to Pixel” and its vertices equivalent set to off in both the project and on the subviewport.

So I guess I’m asking for either A) a way to smooth out the jitteriness or B) a way of rounding position that doesn’t affect the speed of movement. Anything helps; at this point I’ve been trying things for about seven hours and I don’t know what else to do.

Cheers!

1 Like

Okay, fixed it. It turns out it was caused by the fact that the subviewport’s scale was set smaller than the size that it was being displayed in-game. Who knew?

1 Like