Road TO Dev — That’s a lot of lasers…

Well we did it! We made our character fire those lasers but now if you notice something in the inspector… they live FOREVER!

That just won’t do we need to make sure the lasers go away when they are either off screen or when they hit something. We will cover collisions soon so for now let’s just focus on when the laser leaves the screen. This is easy to do. Just decide where on your screen in the Y axis you want to be considered “off screen”. You can do this by just dragging a laser into the hierarchy and dragging it to the top edge. Then look at it’s Y coordinate and bingo you have your number.

Now that we have that number let’s just create a check in the laser script to Destroy itself when it reaches this value.

Now you can see in the hierarchy that once the lasers reach their limit they are properly disposed of. This is a must have as you don’t want your game getting bogged down.

--

--

--

Hi there! I am currently on the path to learn how to become a unity developer and will be documenting my journey as best as I can here. Thanks for looking!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to prepare for AWS SysOps certification exam?

Introducing FugueSQL — SQL for Pandas, Spark, and Dask DataFrames

Set up a CI/CD Pipeline for your Webapp on AWS with Github Actions within 5 minutes

Unity Dev: Playing with Fire

Location spoofing on Android.

Case Study: Industry use cases of Jenkins

Hive: Flutter Local Data Storage With Hive | TypeAdapter

Finally, InsureDAO testnet is out on Rinkeby testnet today, 6th August at 4:00 PM (UTC) !!

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
Rob Smith

Rob Smith

Hi there! I am currently on the path to learn how to become a unity developer and will be documenting my journey as best as I can here. Thanks for looking!

More from Medium

Skeleton Damage Animation

Using Decals in Unity

My journey becoming a Unity game developer: Sleeping Guard Interaction-Player NavMesh movement…

Unity and Object movement