One pixel line bug

Godot Version

4.4.1

Question

Ask your question here! Try to give as many details as possible
So I’m following this Godot tutorial as I’m new to the engine and have this bug where my slime enemy will very briefly have a small one pixel line appear above it during its animation. The slime move from left to right, turning at each wall while playing an idle animation. The enemy is talked about around 42:00 in the video. This is what it looks like:

It could be an issue when you added the sprites and you accidentally increased the y-offset of the spritesheet. From what I see, it looks like the bottom pixel row of your enemy sprite has been cut off. Try adding the sprites from the spritesheet again and see if the offsets are at 0.

1 Like

I tried reimporting them and made sure they had no offsets but it is still happening. I also tried updating my graphics drivers to see if that was the problem but nothing changed.

I think @mrdicerack is probably on the right track; that looks to me like the bottom edge of the cell above. I’d suggest redoing the sprite sheet with a 1 pixel transparent border around the cells; make them 26x26 and only use the inner 24x24. You can then set offset and separation in your sheet to compensate.

I was able to fix it. I think it had to do with the camera moving and it was messing up the rendering or something. To fix it I went into Project → Project Settings → Rendering → 2D → Snap 2D Vertices to Pixel : On (If you cant see it enable advanced settings in the top right)

I’m not sure why this works though so if anyone can explain that would be helpful.

If you don’t have things snapped to pixel dimensions, the sprite draw might bleed a fraction of a pixel outside of the cell due to roundoff error. Generally it’s good practice to put at least a 1px clear border around sprite cells to avoid this.

Ah okay thanks. I was just using the assets from the tutorial which don’t inherently have a one pixel border so that’s probably why.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.