A lightning round of great tips for 2D games

Are you planning to make a 2D game with Unity? Then take a look at these handy tips from our 2D Technical Product Manager Rus Scammell and 2D Product Marketing Manager Eduardo Oriz, that will help you get started quickly and work efficiently throughout your entire project.  

Start your 2D projects with the 2D Template

Use the 2D Template to get started fast with a new project. The template is available from the Unity Hub. Unique settings include: 

  • A default scene that uses a 2D view and comes with a camera set to orthographic projection and clears to a solid color
  • The Editor set to 2D Mode by default so that new textures are imported as Sprites 
  • Real-time Global Illumination disabled 
  • Installation of 2D packages, including 2D Animation, 2D Pixel Perfect, 2D PSD Importer, and 2D SpriteShape, as well as the necessary dependencies 

    From 2020.2 onwards, the 2D menu items are displayed as top-level menus for GameObject and Asset creation. These include a set of primitive 2D Sprites for quick prototyping. Menus are also added for newer features such as SpriteShape and the Pixel Perfect Camera. 

    Choose the pixels per unit of your Sprites

    Pixels Per Unit (PPU) is an important concept in 2D development. A Sprite’s PPU determines how many pixels of width or height in a Sprite image correspond to one unit of distance in world space. 

    Consider the PPU of your Sprites as early as possible. Apart from controlling pixel density, the PPU also affects how Sprites are used by the Sprite Renderer draw modes as well as other systems like Tilemap. Choose a pixel density that suits the design of your game and target platform, and avoid unnecessarily large textures. 

    Use the 2D PSD Importer

    The 2D PSD Importer imports layered Adobe Photoshop PSB files into Unity. It enables you to use features such as Mosaic to automatically generate a Sprite Sheet from the imported layers and character rig. Unity then reassembles the Sprites of a character as they were arranged in their source files. The Importer is designed to work optimally with the 2D Animation system and multilayered character workflows.

    Reduce overlapping pixels

    Aim to reduce the number of passes required to draw the final color to the screen. When pixels are semi transparent, you must consider each overlapping pixel when calculating the final color. Overdraw of overlapping transparent pixels slows down GPU performance, especially on less powerful devices or when higher frame rates are required. All of the Sprites in your scene will be considered transparent, but there are ways to reduce the overdraw.

    Unity will overdraw the pixels only inside your Sprite Mask. With full rect, the complete area will overdraw, but if the Mesh Type is set to Tight the area to overdraw is reduced since the generated mesh follows only the outline of your Sprite, ignoring the empty areas. If you want to have more control over the outline of the mesh, you can change it from the Sprite Editor.

    You can also reduce overdraw by merging overlapping static Sprites. If the Sprites don’t have to move or you don’t need them for a parallax effect, consider merging them once your level design is finalized.

    Combine Colliders

    When you have

    Continue reading

    This post was originally published on this site