Quick answer: Use System → Create Object with an explicit layer parameter, not Sprite → Spawn Object which inherits the spawner’s layer.
Player on layer “Background” fires bullets via Spawn Object. Bullets appear behind walls drawn on “Foreground”. Spawned objects went to the player’s layer; you wanted them on the gameplay layer.
Spawn vs Create
Two actions for instantiation:
- Sprite → Spawn Object: creates at the sprite’s position on the same layer. Convenient but no layer control.
- System → Create Object: explicit X, Y, Layer parameters. Use when layer matters.
The Fix
On player shoots:
System Create object Bullet on layer "Gameplay" at Player.X, Player.Y
Bullet appears on the gameplay layer regardless of player’s layer. Z-order correct relative to walls and enemies.
Default Layer Property
If you always want a specific object on a specific layer, set it on the object itself:
- Select the object in the Project bar.
- Properties → Spawn Layer Option = “Custom”.
- Set Spawn Layer = “Gameplay”.
Now Spawn Object on this object always uses the Gameplay layer.
Layer Index vs Name
You can pass a layer name (string) or index (int). Names are stable across reordering; indices change. Always prefer names for cross-layout consistency.
Verifying
Shoot a bullet. Inspect the bullet sprite in Play mode; it should be a child of the Gameplay layer in the debug inspector. Visually: bullets should draw in front of background but behind UI.
“Spawn inherits layer; Create lets you specify. For multi-layer scenes, use Create.”
Audit Spawn Object usage when adding new layers to a scene — previously-correct spawns may end up on wrong layers post-restructure.