godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.45k stars 21.27k forks source link

Overlapping nodes on y-sorted TileMap "jump" back and forth #30831

Open giulianob opened 5 years ago

giulianob commented 5 years ago

Godot version: 3.1

OS/device including version: Windows, Radeon R9 200 series

Issue description: I have two nodes that are overlapping (exact same x/y position) on a y-sorted TileMap. The nodes will swap places randomly and Node A will be in front of Node B then randomly Node B will show up in front of Node A.

I'm guessing the algorithm that sorts the nodes is not deterministic. I would recommend that the sorting should probably just fallback to the node's index in the parent to decide on ordering if they overlap OR just make it deterministic so it doesn't jump back and forth.

Steps to reproduce:

  1. Add 2 sprites on the same x/y position
  2. Have other sprites that are moving around to force the engine to have to re-sort children.

Minimal reproduction project:

YSortBug.zip

See video. There are 2 sprites on the top left tile which will jump back and forth. The other nodes that are animating to the right/down are there just to force sorting to happen. ysortbug

KoBeWi commented 4 years ago

Still valid in fea72f2a7