I have started a 2D top-down project recently and I have begun to look for tutorials on how to create 2D games with Unreal. There were some good basic tutorials to start, but they are almost all exclusively for 2D side-scroll games and really don’t go enough deeper on how to create a good production pipeline in 2D with the engine.
One thing that bugs me at the moment and that differ between the two types of game is the rendering order of the sprite based on the Y axis: if I’m in front of a tree, then my head should be rendered on top of it; if I’m behind the tree, then my feet should be rendered on the back of it.
On top of that, I have added on the tick of my Paper Character base class, an offset on the Z axis base on the Y and the tile size of my map to match this. And I had good results.
But there is one issue with all of that. Like what is written in the description of the “Separation Per Tile Y” property, “batched tiles will be put on the same Z”. And I have this causing issue to me :
Big sections of my TileMap seem to be batched together and totally break this feature.
Batches would indeed be nice for some graphical elements based on multi tiles (like a tree again). But I can’t find out how the hell the batches are creating themselves, it seems to be automatic and that I can’t control it, so it just ■■■■■■ me off.
I’m really starting to think that I will have to abandon the idea to use TileMaps and recreate my own system with a grid of PaperSpriteActors… but I can’t believe that UE is that crappy to handle 2D games and I have found no help on the internet for now.
I know this kind of games is not very popular with this engine. Although, do people have already worked on similar projects and agree to talk about it ?
Hey there @Wikiful! Welcome to the community! I believe you might be able to get some use out of heading to your project settings and adjusting the translucency sort policy to sort along axis and set it to the axis you prefer to sort on.
Hi SupportiveEntity !
Thank you so much for your answer.
I have tried to set the setting and to disable the Separation Per Tile Y, so my player’s sprite and the Map Tiles are on the same Z. Unfortunetly it is not working, the player is most of the time of top of everything or we can see a glitching artefacts where both sprites are overlaping.
It doesn’t to be affected by the Y axis either.
The easiest way to get your desired effect is to separate your tilemap into layers, f.e. one background/main layer, and one foreground layer. Everything, that is at the same height as the player can go into the background/main layer, everything, that should be able to be on top of the character, or to cover him, can go into the foreground layer.
In that video i just forgot to turn on subsurface scattering for the tents, so the upper part looks kinda bad. Rest is the same, the tents are still separated into two layers.
PS: all that sorting stuff only works for translucent sprites, and the moment you switch to masked sprites, nothing of that works anymore. But unfortunately, for better lighting, masked sprites work better - f.e. they can cast shadows.
@SupportiveEntity Is there actually any chance, that Epic will finally get orthographic cameras/perspective working with the normal lighting? It´s broken since ages and the rest of Paper2D related stuff also needs several updates. Tilemap Editor is still marked as Beta -.-´
Ahhh understandable! I’d recommend checking out Suthriel’s option, as the last alternative I have would be to manually handle Zorder but that gets to be a bit harder.
Didn’t mean to skip over your question in that response, but unfortunately I haven’t seen any information on if the 2D suite will be getting any updates, but I don’t believe it’s the current focus of the engine itself since much of the recent focus of 5.0+ has been the integration and getting production ready of nanite/lumen. While it’s not out of the question, without any new announcements about 2D utilities, it might be best to roll your own custom systems for it. There’s a pretty wide market plugin gap for something like that if you end up getting it stable!
The main issue for many 2D creators is, that they sooner or later figure out, that the whole 2D part is essentially abandoned by Epic since ages. And we are talking about years without any updates to fix essential 2D stuff like the orthographic camera.
The orthographic camera is basically broken since UE 4.0 ( Orthographic Camera Render broken 4.0.2 ), and it got never fixed.
We got even some hope for UE 5.2 because of posts like this here:
but that seemed to be cancelled again.
Don´t get me wrong, nothing of that is your or any other mods fault. But if essential 2D parts are getting ignored since 4.0 or in years, since 2014 (almost a decade), then thats not a good outlook, especially if some other parts of Epic seem to actually like 2D, proof of that is the Megagrant for PaperZD ( https://www.unrealengine.com/marketplace/en-US/product/paperzd ).
And i guess, threads like this here wouldn´t even be necessary, if Paper2D stuff would get some updates
And again, hope you understand, that this is not against you, you are infact one of the really helpful and nice people here, it´s just, that Epic should really reconsider some fixing and updating on long broken stuff.
I really liked your message @Suthriel.
The fact that the engine handles these types of 2D games so poorly really surprised me, especially when I see how good it is in other aspects. It seems fundamental to me that an engine be at least ready for 2D. And on this, it is Unity which benefits from it.
PaperZD is a must-have, and even though it’s almost an official plugin now, I’m also worried that it’s not something available natively. Where this fixed the 2D animation framework, many other basic aspects don’t seem to be present, and with no free MegaGrants plugins to the rescue.
I think I will go with your solution Suthriel. Thank you for sharing it !
I don’t like the idea of splitting an element’s tiles onto different layers, but my levels won’t be that big so I won’t mind that much.
I am now working on another problem, as my game is grid based, I need to define for certain tiles blockers in certain directions. Like so :
I have now fully embrace that I will not find an appropriate framework in the engine and will have to create my own. Maybe if my company accepts, I’ll be able to give it on the marketplace in the end
Love to the devs ofc. They are doing very great things.
Hope these subjects will receive some light still.
Thank you also @SupportiveEntity for your help and to give us more visibility on this.
For this one sided case, you could create a tileset, where your raised platforms have some kind of overhang or cliff, that takes up half a tile. Then you could give those cliff tiles collisions, and with that make them block anything, that tries to wander against them. A tile witha ramp for up and down walking should be left open/without any collision.
The blue marked tiles got a box collision. If you then enable collision in your tilemap, then those tiles will have valid collision boxes on them.
The other way is, that you give some tiles a custom collision shape, that sits only on the edges. Then during walking, you only check (via a short range line trace or box trace), if the first half of your next tile is free, and then walk. while during walk you don´t do any checks. With that, your char can walk onto a tile with such a custom shape, but then cannot go any further into that direction, where the custom shape sits.
Here is an example formed out of two boxes, where i then just selected some points and moved them to form those small rectangles.
I use Actor classes just like a 3D game and use components to turn them into a “sprite”, works well for objects and pawns. That way you can store depth differences within an actor (such as bed + blanket) in an actor and place that actor at any depth in a level. Keeps it all properly relative instead of having to deal with a few layers for an entire level. Actors have lots of other benefits as well (gameplay, networking) over just a background sprite.
That thing you are doing now, creating Z depth by curving the 2D level? that’s asking for problems.
I didn’t wanted to go through this first, as I thought it would be too weird for the player to be stuck so far from the edges (because the player can only move from tile to tile in my project).
I started imagining a way to encode in the tiles that directions could be blocked by placing a collision shape of a single vertex in their direction.
Here I could have blocked moving left and right on this tile (no matter what is to its left or right). And ofc, a shape of a single vertex is nothing, it’s just a way for me to encode it into the tile’s metadata to read it at runtime.
It would have taken a bit of time to get it working, but I think I could have come up with something.
Anyway, I tried to see if creating a Blockout TileSet with blocking edges was that disturbing…and it’s good enough!
The final result :
Blocking Ground layer :
Walkable Background layer :
The player will be just above the ground layer to appear in front of it. And anything we put to the ground layer should have a blocking collision. This way there would be no weird overlapping issue with the player.
Then we could have as many Background layers below the Ground layer as we want, the same for Foreground layers above the Ground layer and the player.
I think I started to find a good way to make my project work. Thanks again for your support !
No worries, I don’t take it personally, all software has it’s limitations at the end of the day and I understand it’s frustrating! Just came back by to let you know that I’ll be leaving some notes in a community report about community desire for more 2D support. Just wanted to let you know we hear you, regardless of where the project leads.