Unity 3D Tutorial – Add and Remove 2D Game Objects Using Touch Controls

In this tutorial we will explore how to add and remove 2d Sprite images using Touch Controls in Unity 3D using C# Programming. This is going to be the first 2D project we do in the Mobile Development series so its exciting to see how this one will work out. We have got 6 different images to add to this project and as we are dynamically adding sprites to the scene we will also randomize the items in the sprite images and it will choose one out of the six images to apply to the sprite at a time.

Lesson objectives –

  1. Create a project in unity that spawns and destroys game object on touch
  2. Work with a 2D Game Template in Unity
  3. Using custom function to determine the touch position and spawn game objects on empty space
  4. IF the touch happens on a game object destroy it from the game
  5. Using Mobile 2D touch controls
  6. Using Unity Remote with a Android Device
  7. Using 2D sprites and Lists to spawn random objects to the scene.

 

Full Video Tutorial On how to add and remove 2D objects in unity using C# programming

Download images for the 2d touch control project here

 

Add and Remove Items Script

This script will be attached to the Camera in the scene.

 

 




Comment on this tutorial and let us know how you got on -

%d bloggers like this: