Day 5

Put in a few hours today, and managed to get through a couple of challenges. First challenge was to create an enemy. To do this we added another gameObject and colored it red as you can see in the image. Then of course we needed to give the enemy movement so the next challenge was to allow it to move down on the Y axis. This gives us the perception of flying through space. In order to do that I used to code writing we had learned about how to control the transform. the transform is a part of every gameObject and it tells us where the object is based on the axis. So by writing some code of transform.Translate(Vector3.down * _speed * Time.deltaTime); we were able to tell the gameObject to travel down at a rate of speed( also had to define _speed as a variable and assign it a number) and to do this at real time, which is what Time.deltaTime stands for.

Once we had given our enemy some movement we then had to make sure it was going to regenerate so we can keep playing. To do this we create an “if” statement, that will create a true or false scenario. We look at the point in which the object disappears from our screen and we use that as the reference to say when we want the object to re-appear at a different location. And in this case we would look at a point just above where the object comes into view on the screen. Then we would say “If the object is at this point, then make the object appear at this point instead”. Finally we want it to appear in random spaces so I got to learn the Random.Range concept where you select a range say 1–10 and the object will appear anywhere between those numbers on the axis you select.

Final challenge I took on today was the start of what happens when a gameObject collides with another object. I just finished applying the code that tells the game to destroy the enemy if it collides with either the laser or the player. Tomorrow is another day and I am hoping to make some serious progress with the way the game plays and functions.

--

--

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.