Ensuring new sprites render over existing sprites

Let’s say i have sprites that are in the same sorting order and same layer. Is there ANY WAY i can ensure that a newly instantiated sprite will always render over an existing sprite if they’re in the same layer and sorting order.

I tried the following which maybe helped, not sure:

Sprite is instantiated in a higher layer, but upon certain things happening the layer is changed to a lower one and a brief time later the sorting order is also lowered by one. At this point new sprites can go over the old sprite. This means new sprites are ALWAYS at a higher layer and sorting order starting out. But i still get some sprites starting to render under old sprites ones their layers and orders are set the same.

To make it clearer.
I spawn a live enemy, layer “dafault”, order 0.
If enemy dies, layer is set to “dead” which is lower than “default”, order 0.
2 seconds layer, order is set to -1.

But it doesnt prevent it from rendering beneath older dead enemies ONCE the order is set to -1. WHYYYYY!!!

Umm ok i figured it out myself lol

Not setting the order to -1 fixed the problem.
It seems that either changing the layer still keeps the sprite rendered on top of an older sprite that is already that layer


If an animation is playing while the layer is changed keeps the sprite rendered on top.

Both things occur in the game, somethin worked.