Day 14…Guess I lost track of time

Its so true how when you really enjoy something you can loose track of the time and even the days. Today was day 14 of learning all things C# and Unity and I am ending the day feeling pretty good. My start to the day was to fix my enemy laser fire. Yesterday when I ended the enemy would fire but then would instantly blow up and the lasers would too. Turns out someone else has this same problem and the issue was not in the coding but with the box colliders! My laser was being instantiated too close to the enemy, and vice versa the box collider on the enemy was set too wide. So when a laser was instantiated it would just destroy both my enemy and the laser as I had told it to do so.

As you can see in the above image my lasers were just inside of the box collider. After I corrected this everything worked just fine. I then added a quick “quit” or “esc” from full screen button for when you are in full screen. I had never though about it before, but anytime you see “to exit full screen press esc” that has to be programed in. Crazy right! Now I have finally caught up to my team and am working on the phase 1 framework, the training wheels are off and its up to us to figure things out. At this point of the course there are no more videos to help problem solve. We have to do our own independent research and figure out how to make these things happen. Such as when you push “this key” make the player go faster, and when you “release the same key” the player should move at normal speed.

In order to make that work I implemented the following logic. I added a new method of “void FastSpeed()” and wrote in my If statements for what to do when the key was pressed and released. This also requires a “bool” to tell it if the “fast speed” was active or not. Then I called that method into action in Void Update so that way it is always active, but will only activate when the button is pressed. It felt really good to nail that one all on my own. I had been thinking maybe I was not learning fast enough, but considering I was able to write this logic without even looking anything up, and 14ish days ago I had never written a single line of code before, I would say its starting to sink in. I ended my day with a challenge to give my player an ammo count. After all its no fun if you have unlimited ammo. This was fairly straight forward of creating an int(Integer) for the player called “ammoCount” and then using that in its own method called PlayerAmmo. Within this method it does all things ammo, it tells the player how much ammo they have, it says when the ammo goes down, and I even put in a coroutine that makes the player wait for 5 seconds when the ammo runs out. I’m thinking about turning that function into a power up of sorts later on. I then added some text telling the player how much ammo they had on screen, and hit a little snag on the functionality. But with a little help from one of the team leads we got it working so that every time I fire a shot my ammo count goes down. I attempted my first shot at a screen recording and hope you enjoy!



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
Joe Kuka

I am a self taught game developer and love pushing myself to learn new things.