0 votes

My game has three types of tiles with colliders: pits/flat obstacles, half-height obstacles, and full-height obstacles. The bullets shot by the character are supposed to go over the half-height obstacles, unless he shot fired them while crouching. I've implemented this by having three separate tilemaps. One for ground and pits (with collision layer 1), one for everything that protrudes over the ground (CL 1 & 2), and a hidden one which repeats all the full-height tiles (CL 1, 2, & 3).

Basically, layer 1 is for player collision and the other two are for two bullet heights. When it comes to collision detection, it works like a charm. But I don't know how to make the layer-3 bullets be drawn over the low obstacles without breaking the Y-sorting.


Any ideas?

asked Jan 11, 2018 in Engine by Ishari (15 points)

1 Answer

+1 vote
Best answer

Use the Z coordinate under 'Node2D > Z'.

answered Jan 11, 2018 by mateusak (1,023 points)
selected Jan 12, 2018 by Ishari

Which Z? If I set the bullet's Z to 1, it doesn't get occluded by the tall block (and I want it to). Changing Z's of the tile sprites does nothing.
enter image description here

Change your testBullet's Z to 1 and your HighTiles's Z to 2 (not the individual sprites, the actual TileMap node)

Then I get this monstrosity:
enter image description here

Unless I hide the HighTiles or set the LowTiles' Z to 2 too. But that brings me back to square one.

I'm pretty sure that would be solved by an YSort node. Create it and put both LowTiles and HighTiles nodes inside it.

No, it would mess things up even more. But this should work: keep all Zs at the default 0, but when a bullet flies over a low tile, its Z temporarily changes to 1. Thanks!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.