Sprites changing size and/or position when character moves

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

This is a duplicate post, but I originally made the question far too long, and included a bunch of my own ideas that aren’t likely helpful. I tried to edit that post and bump it, but it stayed burried, so I’m reposting the new (hopefully improved) version of the question here.

I’m just going to share the gif, and hopefully it’s something that someone recognizes. I’m sure it has to do with import or project settings or similar.

Basically, my sprites are deforming in different ways when I move the player. Sometimes they shift in one of the cardinal directions, and sometimes they expand or contract on the x or y. It happens regardless if the camera moves.

The title says “Unity Problem” but that was just a mistake when I posted it. This is in Godot.

Thanks.

  1. Test the ‘pixel snap’ setting in project settings?
  2. How are the sprites added to map? Not tiles?
  3. How does map ‘move’? Move map and all children or move only camera?

rakkarage | 2020-10-11 15:08

Thank you.

  1. I have turned Pixel Snap on and off (assuming you mean (Project Settings → Quality → 2d ->Use Pixel Snap)
  2. Tiles, Node2d objects, and StaticBody2D objects all have the same behavior. In the gif, the Trees and Bushes are StaticBody2D, the cliffs are a tilemap, and the smaller grass clump is a Node2D.
  3. The camera moves. It is following the player via a remoteTransform2D. I have also tried making the camera a child of the player for testing, and it acts the same. If I leave the camera static the problem goes away.

I’ve also tried setting the camera to Physics and Idle Process Modes, and changing all script methods between process and physics_process to both match that and to the oposites of what would match (eg. physics_process function and camera set to Idle).

I’ve also tried exporting the game instead of running it in the editor.

Edit: I just noticed that in the gif the cliffs never show the problem, but they do sometimes. It seems almost random what everything acts like from one run to the next.

acecase | 2020-10-11 22:40

maybe related?
https://github.com/godotengine/godot/issues/35606

rakkarage | 2020-10-12 01:43

Thank you. That is exactly the problem.

The short version is that pixel snap isn’t used by Camera2D, so if you use a moving camera you have to implement that in code. The fix is pretty simple, and camera smoothing is easy enough to implement. It’s a little disappointing that turning on pixel snapping and camera smoothing doesn’t just work though. Cameras following the player aren’t exactly rare.

acecase | 2020-10-12 04:43