I’m working on a treasure chest loot system in GDevelop where the chest spawns one item when opened—either a heart, a big coin pile, or a bomb trap—based on the player’s health.
The logic is working, but there’s a visual issue: the loot doesn’t look like it’s coming from inside the chest, and it’s not centered properly when it spawns.
What is the expected result
When the chest is opened, the loot should spawn from its center and appear like it came out of the chest.
This should work correctly even if I have multiple chests in the scene.
The spawn should look smooth and natural, ideally enhanced with a little scaling or smoke effect.
What is the actual result
The loot sometimes spawns to the left or right of the chest, or too high above it.
It doesn’t visually feel like the item is coming from inside the chest.
1 - each of your loot objects i assume bomb coin and heart
You should double click go to points and then move origin point to center point
2 - this your chest should be 2 objects
Bottom part and top part both separate objects
Now for example z order of bottom part should be 3
Top part z order 1
Created loot under action to create it should have change z order to 2
My chest is a single sprite object and it has a “chest open” animation that shows that the chest opens. And I am unfamiliar with the role of z-order because I am a beginner. I don’t think this will solve the issue that i am facing.
If you are unfamiliar with Z order then how you know it will not solve your problem?
Z order is like this
Imagine you have cards like 3 of them
You put them together so they form a deck
So one of them is 1st other is 2nd and last is 3rd
So bottom middle top
And z order would be 0 for one which is on bottom and for on in middle 1 while on on top would have z order of 2
NOW you understand you just ordered them from bottom to top
NOW imagine you can change which card is 1st or last by changing their Z order
That is whole concept of Z order
You change what is in front and what is in back
So if your chest would be 2 objects and not 1
You could put top part behind bottom part but in front of top part
And now it would look like loot is coming out of your chest
Thanks for explaining. My chest is not 2 separate objects i.e 2 separate parts. It is a sprite that has open and close animation. That’s why the z-order approach will not work.
Yeah, if they were 2 objects then probably your approach would have worked. Fortunately, I solved both of the problems that I was facing after some trial and error.