Part 12 — Shooting System> Code Cleanup

Timothy Hutchings
3 min readOct 26, 2022

--

Now that we have the basics of our laser code set up, we want to go through and make sure things are as cleaned up and organized as we can get them.

We’ll start with the laser script.

Here is what we have so far. We can start the clean up by clearing out our pseudocode.

Finally we can actually go ahead and remove our void Start block, as we have nothing there and don’t really need it.

So our cleaned up laser script should look like this:

The only comment here is the one that came with the script for the Update section.

Now into our Player script.

A lot more going on here, but only a little to do with our laser system, namely the instantiation If statement, and our variables.

Not much we can do about the variables, but we can clean up the code and add in a new void that we will call Fire Laser. Inside that we’re going to put the CONTENTS of the If statement, and replace those with the Fire Laser void name.

One great thing about having void blocks is you can minimize certain sections, which I will do for the movement block so we can better see how we finalized our Fire System code. So don’t panic if you don’t see that translation code after this. It’s still there. Just hidden.

Pretty simple clean up this time around! Good job!

Good luck!

--

--