11 simple and easy tricks for Unity3d 2d game development.

Are you looking for ways to improve your 2D games in Unity3D? Check out these useful tricks for optimizing performance, creating compelling visuals, and enhancing gameplay

1. Use the Sprite Packer to improve performance by packing multiple sprites into a single texture atlas.

The Sprite Packer can improve the performance of your 2D game by reducing the number of draw calls required to render the sprites, which can help improve the frame rate of your game. To use the Sprite Packer, first select the sprites you want to include in the atlas by either selecting them in the Project window or in the Scene view. Then, go to “Edit > Pack Sprites” or right-click the selected sprites and choose “Pack Sprites” from the context menu. This will create a new sprite atlas asset in your project that contains all the selected sprites. You can then use this atlas in your game by assigning it to a Sprite Renderer component as the “Sprite” field.

2. Use Sorting Layers and Order in Layer to control the rendering order of sprites.

Sorting Layers and Order in Layer are particularly useful when you have sprites that overlap and you want to ensure that they are drawn in the correct order. For example, you might want to ensure that a character sprite is always drawn in front of the background. To use Sorting Layers and Order in Layer, first create a new Sorting Layer by going to “Edit > Project Settings > Tags and Layers” and adding a new layer in the “Sorting Layers” list. Then, select the Sprite Renderer component of the game object you want to change the rendering order of, and set the “Sorting Layer” field to the layer you just created. You can then use the “Order in Layer” field to specify the rendering order within that layer, with lower values being rendered first.

3. Use Sprite Masks to hide or reveal parts of sprites.

Sprite Masks are useful for creating a variety of visual effects, such as vignette effects around the edges of the screen or revealing parts of a sprite as it is collected by the player. To use Sprite Masks, first create a new Sprite Mask component by selecting “Component > Miscellaneous > Sprite Mask” in the menu or by right-clicking the component list in the Inspector and choosing “Sprite Mask” from the context menu. You can then assign a sprite to the “Mask Graphic” field to use as the mask. Any objects that are behind the mask will be hidden from view, while objects in front of the mask will be visible.

4. Use Sprite Animations to create simple animations by flipping through a series of sprites.

Sprite Animations are a quick and easy way to create simple animations such as character movement or object interactions. To use Sprite Animations, first create a new Animation Clip by going to “Asset > Create > Animation” in the menu or by right-clicking in the Project window and choosing “Create > Animation” from the context menu. Then, select the Sprite Renderer component of the game object you want to animate, and drag the Animation Clip asset onto the “Animation” field in the Inspector. You can then use the Animation window (Window > Animation) to create a series of keyframes that flip through different sprites to create the animation.

5. Use Physics Materials to control the physics properties of colliding objects, such as bounciness and friction.

Physics Materials are useful for creating realistic physical interactions, such as a ball bouncing off a surface or an object sliding along a floor. To use Physics Materials, first create a new Physics Material asset by going to “Asset > Create > Physics Material” in the menu or by right-clicking in the Project window and choosing “Create > Physics Material” from the context menu. Then, assign the Physics Material asset to the “Material” field of the Collider component on the game object you want to modify the physics properties of. You can then adjust the “Bounciness” and “Friction” properties of the Physics Material to control how it reacts to collisions.

6. Use Box Colliders and Polygon Colliders to define the shape of game objects and control how they interact with other objects in the scene.

Box Colliders and Polygon Colliders are used to define the shape of game objects and control how they interact with other objects in the scene. To use Box Colliders and Polygon Colliders, add a Collider component to the game object you want to define the shape of. Select either the “Box Collider 2D” or “Polygon Collider 2D” option from the “Type” dropdown to specify the type of collider you want to use. For Box Colliders, adjust the “Size” and “Offset” properties to control the shape. For Polygon Colliders, use the “Edit Polygon” button to manually specify the shape by clicking to add points.

7. Use Layer-Based Collision Detection to control which game objects can collide with each other.

Layer-Based Collision Detection allows you to control which game objects can collide with each other. To use Layer-Based Collision Detection, first create a new layer by going to “Edit > Project Settings > Tags and Layers” and adding a new layer in the “User Layers” list. Then, select the game objects you want to include in the layer and set the “Layer” field in the Inspector to the new layer. You can then use the “Layer Mask” field of the Collider component to specify which layers the collider should collide with.

8. Use Trigger Colliders to create events that are triggered when a game object enters or exits a collider.

Trigger Colliders are used to create events that are triggered when a game object enters or exits a collider. To use Trigger Colliders, add a Collider component to the game object you want to use as the trigger, and check the “Is Trigger” checkbox in the Inspector. You can then create a script that contains a function with the “OnTriggerEnter2D” or “OnTriggerExit2D” signature, and attach the script to the game object. This function will be called whenever another collider enters or exits the trigger collider.

9. Use Raycasts to detect objects in the scene and perform actions based on their presence or absence.

Raycasts are used to detect objects in the scene and perform actions based on their presence or absence. To use Raycasts, you can use the “Raycast” function of the “Physics2D” class, which returns a “RaycastHit2D” object containing information about the object that was hit by the ray. You can use this information to perform actions such as detecting when the player clicks on an object or when an enemy collides with a wall.

10. Use Particle Systems to create special effects such as explosions, smoke, and sparks.

Particle Systems are used to create special effects such as explosions, smoke, and sparks. To use Particle Systems, first create a new Particle System by going to “GameObject > Particle System” in the menu or by right-clicking in the Hierarchy and choosing “Particle System” from the context menu. You can then use the Inspector to customize the appearance and behavior of the Particle System, such as the type of particles, the emission rate, and the lifetime of the particles.

11. Use Tilemaps to quickly create levels using pre-made tiles, and use Tilemap Colliders to define the shape of your level and make it interact with other objects in the scene.

Tilemaps are used to quickly create levels using pre-made tiles. To use Tilemaps, create a new Tilemap by going to “GameObject > 2D Object > Tilemap” in the menu or by right-clicking in the Hierarchy and choosing “2D Object > Tilemap” from the context menu. Customize the properties of the Tilemap in the Inspector, such as the size of the tiles and the offset of the grid. Use the Tile Palette window (Window > 2D > Tile Palette) to create and paint tiles onto the Tilemap. To make the Tilemap interact with other objects in the scene, add a Tilemap Collider component to the Tilemap game object. This will create a collider for each tile in the Tilemap, allowing other colliders to interact with them.

Photo by ThisIsEngineering on Pexels.com

By using these tricks, you can take advantage of powerful features such as the Sprite Packer, Sorting Layers, Sprite Masks, and more to elevate your 2D games to the next level. Whether you’re a beginner or an experienced developer, these tips and techniques can help you get the most out of Unity3D.

How do you make a 2D Endless Runner Game in Unity?

I see this question every day.

Have a look at this search on youtube, that place is packed with a gazillion tutorials on every subject and more!


“How do I know if the tutorials are good?” you might ask?

Well, you cant really know for sure. After a while you’ll learn which Youtubers are great, like BlackThornProd, and which are AMAZING like Brackeys.

BUT… Sometimes you just want to have it all in one place, and that’s where SkillShare saves the day.

You can learn all kinds of things there, like Marketing, Programming, Drawing, Design, Game Development, even things like Instagram or getting into specifics on programs like Adobe Photoshop or Illustrator.

Why am I showing you this?

‘Cause my Free Spacerunner graphics pack was recently used in a SkillShare course by SandS Arts and I wanted to share it with you all 😀
So check out the course at SkillShare and get 2 free months of premium where you can learn anything you want!