Homing Laser Unity 2D .2

Thomas Mauro
3 min readJun 10, 2022

--

At the end of Homing Laser unit 2D .1 I got to the point of demonstrating the ammo count work. That was possible because I had the power-up pick-up for the laser. I will start this article (.2) by starting the pick-up. I will try to finish this up here but it may lead to a part 3. Time is minimal during my working periods of W-S 10 hours a day. let's get into it!

The power-up to be collected to add those homing laser ammo was needed. Those things floating down that you collect and give the effects like a triple shot.

  • Empty game object in hierarchy named it HomingLaserPowerup
  • Added powerup script
  • Added an audio clip to the scrip
  • Set the speed and ID
  • Put my rotate script on it and set it to rotate speed of 500
  • added collider 2d of the capsule (should have put a circle lol)
  • Added trusty rigid body 2D
All there. That's what I rolled with. I was turning the post-process volume off and on.
I've seen other ways. For what I needed this works perfectly!

At this juncture in powerup land in my game, this homing laser was number 6.

  • Set that homing laser powerup to work with the powerup script of course. Via its ID of 6 and coming right after the refill ammo powerup ID.
  • Slid over into the SpawnManager.cs to let it know we have another power up just like all the rest.
  • Back in Unity I select the SpawnManager object in the hierarchy and give it one more element
  • Drag and drop the new powerup prefab into the new slot like all the rest
  • Then came the method to tell how many homing lasers you get per each (set via inspector) and set to a specified total amount that can be collected. If the amount is set you zero you get 4 every pickup. If you set it higher you will get that amount on the first pick up. After that, it revets to the code where all homing laser pickups will give the amount hart set in the code.
Set that homing laser powerup to work with the powerup script of course. Via its ID of 6 and coming right after the refill ammo powerup ID.
Simple? Sure if you know what needs to be adjusted.
Back in Unity I select the SpawnManager object in the hierarchy and give it one more element
Then came the method to tell how many homing lasers you get per each (set via player/player.cs/inspector) and set to a specified total amount that can be collected.

There will need to be another one for the homing laser at this point. There is more than has been done and more adjusting. You can play the game at the link below. I made the overall size of the playable space bigger and it seems more fun. This game can only be played in a browser right now with a mouse and keyboard. I will knock out the reset of this homing laser in one last article then move on to other stuff going on in the project. Check it out.

--

--