Hi, I’m making 2D mobile racing game. The idea is that there is a car that camera follows and a track that in particular moment we’re only seeing a tiny part of. When I tried to just make a sprite for the track, it was either too big (100MB+) or the quality wasn’t good enough (as you can see on the screenshot). How should I implement the track, so it is easy to create new levels with different tracks, the quality is good and the size of my game is passable. The track is basically just some shape in different color, it is very minimalist.
Break your tracks up into pieces. Straight, 90degree turns, S turns and the like. Have Unity turn those into a SpriteAtlas then you can use them in the editor to build your tracks. This way you can also have players make their own custom tracks as well if you so desire.
Definitely go with what @Chris-Trueman mentioned. You should be making up your track with multiple sprites. Look into using the Tilemap, could help you out a lot here.
Yea, that was one of my ideas but then the track is pretty repetitive. I can’t make it as irregular as the one in the screenshot. I would prefer some way where I could paint any shape of track, instead of “assembling it from pieces”. Is it possible? Or should I just go with tilemap?
Also do you have any advice on the size of the grid?
Is there any difference in performance between 2 sprites 512x512 and 1 sprite 512x1024. The number of pixels is the same, but then idk what is the difference between one huge sprite and many but smaller.
I apologize if I’m asking stupid or obvious questions, but I just don’t get it.
You could look into a spline based system, it works for 3D tracks. Tilemap would seem repetitive, unless you have enough pieces so that it wouldn’t be as much, but the grid would restrict that.
This is determined by the size of the cars and track. Most people stick with power of 2 sizes(16, 32, 64…) but with a sprite atlas it doesn’t matter sprite sizes as long as the atlas is power of 2.
One larger texture is better(sprite atlas with many sprites on one texture) compared to many textures or individual sprites.
Each texture has some overhead and every time the video card changes textures it creates another draw call which can slow things down. 1 texture with 1000 sprites will be 1 draw call. 1000 textures with their own sprite will be 1000 draw calls. Now given they all need to be on the screen at the same time but its better to have as few textures as possible.
We all had to ask them, its part of the learning process. No need to apologize.
The 2D sprite shape package is quite good for making sprites into irregular shapes: 2D Sprite Shape | 2D SpriteShape | 3.0.18
You could have just a couple sprites, as others mentioned — just use a straight line road sprite and a pink background. Then use Sprite Shape to shape them exactly how you want.
Ohhh, that makes sens, i didn’t think about that. Thanks for the help.
I think, that’s exactly what i needed. I played with the tool for a few minutes, and I have to figure everything out, but it seems like a perfect solution. Thank you a lot!
