Meet Ben D.! He works with instructor Shawn as part of Game-U’s New York Accelerate program. Ben’s determined to master Unity, the professional gaming engine, so he and Shawn took on a series of development projects that teach Ben how to use the engine. Their latest project? A space shooter! Check out the new enemy Ben added to the game.
Having already created the space shooter’s levels, characters, spawners, and health systems, Ben set his sights on a different type of hostile spacecraft – a teleporting UFO. His player ship faces a front of these objects and must target and destroy each of them before moving on to the next level. But here’s the catch! Ben and Shawn programmed a script that takes each UFO object and re-spawns it every second. The UFOs constantly change position as the script generates random points on the X-axis (horizontal axis) of the screen. Once the script obtains the latest set of random numbers, it spawns the UFOs at these points so that the player must keep track of multiple moving targets!

While developing the teleporting UFOs, Ben also got the chance to learn about a new coding concept, inheritance. While human beings often think of inheritance as possessions or genetic information passed down from one generation to the next, programmers think of inheritance as code passed down from a parent class to a child class. Pretend we have a class (or category) called “Person.” The person class defines what a person is, what data is associated with a person, and what functions a person can perform. Since there are many different types of people, however, maybe our program needs child classes – like “Game Designer” or “Student” – that inherit all the information included in “Person,” but add category-specific information and functionality. To keep his game organized and efficient, Ben passed down all his “Enemy” class code to his new UFO child class, which controls teleportation. Watch the video to see his code in action!
Cool stuff here, Ben! Thanks for sharing your project with us. You’re definitely well on your way to mastering not only Unity, but also programming. Keep up the good work!
Leave a Reply