The exercise here demonstrates making the enemy detect the player’s laser and move it sideways to save itself from getting destroyed.

The plan is as followed.

  • Detect the laser presence at a certain distance from the enemy prefab.
  • If laser detected, instruct the enemy to move either left or right at a certain value by checking where the laser’s position is.

To detect the presence, the first requirement is to see which object should check the presence. If the enemy prefab does, by the time the presence is detected, it should be destroyed.

So, there must be another object that…


The exercise here demonstrates making the player magnetic towards free-flowing powerups by pressing the C key.

  • This is doable by the same game manager who handles quitting & restarting the game.
  • It has to check if the C key is pressed at a time and if yes, gathers every flowing powerup in an array.
  • After collecting them, each element of the array should trigger a method that moves it towards the player’s position.

here is the implementation for the tasks above.

  • In the game manager, introduce a check using the boolean to verify the game’s current status and the GetKey(…

The exercise here demonstrates a way to make the enemy prefab destroy a powerup made for the player.

The plan to make this work is as followed.

  • Identify if the prefab in front of the enemy is for the player.
  • Initiate the fire method as soon as identification is completed.
  • If the powerup of any sort gets hit by the enemy’s laser, it should destroy itself.
  • In order for the identification to work seamlessly, the prefabs can be tagged with a preferred name.

The exercise here demonstrates rotating the enemy prefab after it reaches a nearby location to the player and then firing sideways.

Before moving ahead, please make sure you have a new enemy prefab and an associated laser/bullet prefab in place with basic components such as rigid body, box collider, etc.

The pseudo-code is as followed.


The exercise here demonstrates implementing a wavy movement of a projectile being fired from an enemy in a 2D game.

Before moving ahead, please make sure there is a separate enemy prefab and an associated projectile prefab in place.


The exercise here demonstrates a way of introducing a powerup that stops the player from firing for 5 seconds.

The spawn manager takes care of spawning powerup prefabs and the powerup script gives these prefabs speed and collision capabilities. Please make sure that there is a similar configuration at your end to follow along.

First, a prefab has to be created.

  • In order to do it, have a powerup sprite in the project, attach relative collider and rigidbody components to the sprite by bringing the sprite into the project.
  • Please keep the “Is Trigger” option ticket so that it behaves…

The article here demonstrates the implementation of the large pseudo-code written in the previous part.

  1. Create a scriptable object that holds the changing data variables and write public methods to retrieve values of these variables.

A scriptable object gets created via a script. Go ahead and make a C# script, name it as per choice and then make two changes that will convert it into a scriptable object.

  • First, instead of Monobehavior inheritance, make it a “Scriptable Object”. Second, add an attribute named “[CreateAssetMenu]” before the class starts to get it into the project window.

The exercise here demonstrates a solution that took a while to come to its full completion. The objective is to introduce a wave system that depicts game levels with each increment.

Please make sure that the previous articles written by myself contain the foundation building which is majorly used here to achieve the task at hand.

The solution is in two parts. The first one contains the journey to come to this solution and the second one contains the implementation.

Let us get to the problem first.

The game currently spawns infinite enemies until the player dies. An ideal game…


The exercise here demonstrates changing the text of the Text element in a UI placed in the Unity game.

Before going further into this, please go through the article here.

The process is extremely simple and shall not take more than 5 minutes to implement.

  • Since the fire count variable is already set, it could be used to change the text upon the condition of empty ammo as well as real-time ammo count by passing it to the text.
  • The count variable is an integer but the text element needs a string and hence, we need to convert the int…

The exercise here demonstrates an implementation of additional enemy movement that originates from the left-end corner of the screen at an inclined angle, and upon reaching nearly halfway of the screen, it reclines to another angle to exit the window.

Before going further into this, kindly make sure that the enemy and spawn manager objects are in good standings since they are needed to add this feature here.

Here is the high-level pseudo-code.

Samarth Dhroov

Work in Progress.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store