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.

yay, new blogpost and it hasnt even been a full year yet?! Holy crap, something fishy is afoot! … err… jokes aside, I’ve just been feeling very productive lately, and here is the picture to show it πŸ™‚

the new retro style graphics for Twitch Defense

Twitch Defense has really changed a lot visually in the past few days… I decided to go for a sort of modern graphics meets retro style… not really sure how to describe it… I made the sprites in a regular Pixel art style, 16 by 16 pixels, and then applied a few layer styles in photoshop to give it that sort of glowy look to it.

All in all i think it suits the game quite well, let me know what you think ? and give the game a go as well! Wont be long before I can start adding more varied enemies and a couple of new powerups πŸ™‚

yep! Twitch Defense has an upgrade button at last πŸ™‚

currently you can access the upgrade system after you’ve played through the game (aka died… as there is currently no win criteria.. but i am considering making it so that you can select between Infinite Mode and 60 Second mode. But ill see about that πŸ™‚

remember, its still an early work in progress, but im working on it on a daily basis… when rl doesnt butt in πŸ˜›

to those curious, it was made with StencylWorks, a pretty easy to use, yet advanced flash game creation program πŸ™‚

please post comments and let me know what you think about Twitch Defense in its current form… and also, I am very much interested in hearing what ideas on game design you might have πŸ™‚

added a bunch of new graphics and sound effects to Twitch Defense… tweaked the values on the Bonus Object, and i am currently working on adding in an upgrade system that allows you to remove and add bonuses to your player…

for example: removing some of the negatives from shooting bonus objects…

increasing the combo value when bumping into bonus objects

faster bullets

more bullets (currently 1 is the max)

more health in the form of a shield that can take 1 or more hits, depending on upgrade level.

check it out atΒ http://www.stencyl.com/game/play/6462Β and remember, its still a work in progress demo πŸ™‚

I’ve started work on a mini/prototype game and reached a point now with Stencyl where I am actually able to put together a semi-decent gameplay prototype in less than a day πŸ™‚

Its pretty neat being able to whip up a couple of placeholder graphics in photoshop and filterforge, and then put it all together in Stencyl to test out the basics of the gameplay and mechanics for a game idea. I highly recommend trying out Stencyl for prototyping if you’re looking for something to help speed up the process for when you’re making proof of concept for a client or what not πŸ™‚

Twitch Defense (super early work in progress demo)

You control the object at the center of the screen, and your goal is to survive for as long as possible. Shoot the incoming red enemies by pressing the arrow keys in the direction of the enemies.

Dont shoot the green bonus objects, that will give you a negative score… but letting the bonus object hit you, will grant you a big positive score.

I plan on adding an upgrade menu that allows the player to unlock and upgrade new bonuses and features as they play the game more.

Hi all,

 

Figured it was time to show a little somewhat buggy sneak peek of an arena shooter set in space that I am currently working. (read: Currently pulling my hair out because SOMETHING just wont do what I want it to πŸ˜›

http://www.tastygraph.com/sb

 

This test is NOT a proper indication of how the game will play when its finished. All the graphics will be replaced, and Joshua from http://www.openheartsound.com is working on the Music and Sound Effects for the game (I’ve added a few of his sounds to the game already (the laser shot, the upgrade sound and the pick up Ore sound… and damn, is he good!! )

 

also, in the final version of the game, you wont be fighting all enemy types from the get go… it will slowly ramp up the difficulty as you upgrade your ship and kill more enemies.

 

as always, the game requires the Unity3d Plugin to play in your browser, luckily its a super fast download and no hassle install πŸ™‚

 

Just wanted to share a little something, to show that I’m not completely inactive πŸ˜‰

Hi all,

 

Long time, no blog! πŸ˜›

Great news though… Learned a crapton of coding stuff, became a Moderator on http://www.Kongregate.com (one of the largest flash gaming communities) aaaaaand… Kongregate finally accepts Unity3d games to its portal πŸ™‚

So I am happy to announce that Bump n Drop can be played on Kongregate now, and even happier to announce that Bump n Drop is currently ranked in the top 10 of the Unity games on the site… yay me πŸ™‚

 

Visit Bump n Drop on Kongregate!

Yeah, Bump n Drop now has 16 levels… So time to re-Conquer the highscore list and show everyone just how Hillariously Epic Win your Combo Skills are πŸ˜‰

Or perhaps your combo skills are beyond even Hillariously Epic Win? *gasp* Dare I say … Chuck Norris! πŸ˜‰

So what are you waiting for? Go go go!!

http://www.tastygraph.com

Enjoy! πŸ™‚