Hey everyone. Sorry for posting so many questions but I am working rapidly on trying to create a game and have many questions I have figured out how to load multiple tilemaps into my game collection w/ associated collision objects and things are working well. However, I am toying with the idea of using a slight perspective view on the map to give a fake 3D perspective. However, when I set the game to use a perspective camera my sprites become invisible:
Is there a simple way to allow these sprites to render on top of the tilemap surface? I tried experimenting with different Z levels but the sprites never appear. I searched the forum but I don’t see anything which quite answers this question.
EDIT: I’m noticing also, if I destroy an enemy it flies back with an animation. If it flies outside of the tilemap it’s viewable against the black background. So the sprites are rendering but for some reason regardless of the Z value I give them they don’t show up against the tilemap surface…
From the box all 2d objects as tilemaps, sprites, etc are rendering without the depth test, just ordering by pivot’s Z position in view projection coordinare system. In your example a tilemap likely overlaps sprites on this camera angle.
To fix this you can create your own materials (just copy from builtins folder), and set them new tag, see
Then add to renderscript render.draw(my_new_predicate). In this case you can constrol the order of render.
Thanks, I have enabled the depth test in the rendercam script. However, I still don’t see sprites unless I set a very low view distance and then move the camera (following the player) above them (see screenshot below.) If I set the view distance to a “good” higher value then the sprites never render.
function update(self, dt)
if player_ref == nil then
return
end
local camera_pos = go.get(player_ref, “position”)
camera_pos.y = camera_pos.y - 200
camera_pos.z = 400
go.set(“/camera”, “position”, camera_pos)
end
The camera moves around tracking my invisible player, so I know the update loop is working to set the camera position. I tried Near Z: -1200 as well and if I change Far Z to a lower value then the terrain cuts off with a black bar before reaching the top of the screen.
Also, I’ve noticed at certain locations for the camera, even the tilemap is having depth issues (hiding the wall layer and displaying only the background tiles:)
I followed the tutorial here ( The render pipeline in Defold ) and
created a custom material with the tag “sprite” and attached this to each game sprite. Then, I
modified the renderer to render this predicate after the models. Now the sprites show up as expected
However, the other two issues still exist (tiles in the top layer flickering while the background tile layer at Z: 0 remains visible, and the euler.z camera rotation crashing the game.) If anyone knows how to fix these I’d be highly grateful