How I learned to use Unity 3D and write code in just 4 months!
Aloha and welcome to this weeks blog. For those of you that have been following my journey the last few months, Mahalo! And if this is the first post of mine that you are reading I would like to say Mahalo to you as well. This has been a lot of fun learning a new skill and putting it into practice, while also facing many challenges at the same time. Today marks the start of week 8 in my GameDevHQ Intensive Training Program, and day 63 of my 100 day challenge. For the 100 day challenge my goal has been simple, try to do something code related every day and be employed in the programming industry before I reach day 100. For today's blog I decided I should do a full review of my journey so far, and show you just what I have been working so hard on.
Unity is a cross platform game engine used to develop video games, animation, engineering, automotive, virtual reality, and so much more. This engine is one of the most widely used in the world and to my great surprise was very straight forward to learn. There are many code editors you can use with Unity but I elected to use and learn Visual Studio by Microsoft. Being a beginner I would highly recommend this as one of its key features is an Auto Suggest based on the code you are writing. Pair that with an incredible helper tool that explains what you need to use in your code and its very powerful. Part of using this tool though is learning how to use it with Unity, and the program I joined would teach me just that by building video games.
Here at GameDevHQ they do not spoon feed me the information, or have me forever watching YouTube videos, but learning to think like a programmer, and do my own research. I had to learn how to read and understand documentation, so I could then implement it into my project. Now this is not to say there is anything wrong with YouTube, as there is a lot of great information on there by many talented programmers. I just wanted to do something different, and want to succeed in this industry without the need to watch endless tutorials. On Day 1 I had a busy day downloading Unity, and Visual Studio and getting everything set up on my computer. Right at the start I needed to look up some documentation on how to setup the settings in Unity for Visual Studio, and then it was off to the races.
I open up Unity for the first time and this is what I saw… A blank project with a sample scene and a few different windows. I felt like I was immediately trying to read something in a foreign language. None of this made any sense to me, but after some reading and starting my GameDevHQ course I started to get it. So on the top we have the scene view that we use to build our projects and our games. Evey item we place and need to change, move or design will take place in that window. Below it is our game view that shows what the game would look like for the player. To the right is where it gets a a little crazy at first, as here we have the Hierarchy, Project window, and the Inspector. The Hierarchy shows you all GameObjects that are currently in your game, and when it comes to referring to any object in Unity every object is a GameObject. Then below that is the Project window that shows you all the file folders where your data is stores, things like Prefab GameObjects, scripts, audio, animation, images, and much much more. The Inspector to the right is quite possibly one of the most important aspects because this is what allows you to add GameObjects directly into your scripts or create ways for a developer to change settings to the game without needing to access the code directly. When you create a new script in Unity and open it for the first time it looks just like this….
Empty and waiting for you to fill it out. This had to be one of the most intimidating things I encountered starting out. Because I had never written code before and here is an empty script with words I did not understand, that even looked kind of scary since they started with VOID! What does it mean, and how do I fill this out!?! Well to answer that question as I would find out later “void” simply means without value, and the word “Start” followed by () means that this is method. You write the code you want to be executed into a method, and depending on when you want this code to be called will determine the type of method you use. There are many different method groups, some happen before others and some are only called when you say to call them. You can also create methods that ask for a variable or return a variable, which can be very handy. Now that I am getting my feet wet I dove right into the basics of how to create GameObjects in Unity by use of the Hierarchy, and then started learning how to write code to make them do things. In order for that to work you nee to create a C# script and attach it to your game object. Then using code you can tell it to do things like move, or disappear, and even control it with your keys like AWSD. The first game I set out to make was a 2D space shooter game, meaning that you are only moving on 2 planes of horizontal and vertical. This is a very similar effect as the old school video games where you only move left, right, up and down. This game had many challenges of learning how to create GameObjects, and then getting them to talk to each other. As a beginner it was difficult to wrap my head around that concept of script communication, and it feels so good when you make it work.
Above are a few screenshots of the process I went through building this game. In the first pic you can see the background but just a white cube that represented our player. Then in the progressive shots you can see that the player became an awesome spaceship and even gets its own shield!! Below is a video of the finish game, and also one of my first times learning to do screen recordings.
After This I decided in order to get serious I really needed to take this to the next step and signed up for an 8 week intensive with GameDevHQ. This would take me from just barely understanding game development to officially a Padawan in the world of Game Dev. I would be learning how to optimize my code by using an “Event” driven system, focusing on Object Oriented Programing, using an Interface, Dictionaries, custom classes, class inheritance, and many other cool things. So many challenges laid ahead including my first ever live code review and challenge. It took me 2 attempts to pass the challenge but looking back I am so glad I did. After my first attempt when my nerves got the best of me and to be honest I really did need some more work, I spent the whole week just non stop practicing ever code challenge I could find on GameDevHQ. Things like changing multiple GameObjects colors, or moving GameObjects in succession.
Then one of my personal favorites moving around obstacles using something called a NavMesh!
After that week of practice I met with success as my mentor said my code had greatly improved along with my confidence. I was in and super excited to start on this course. Below is a picture and video montage of the game I created during this course, and I hope you enjoy.
So far for this project I had to learn many new concepts as show above. Things like how to implement particle effects, how to create what looks like an attack radius that is transparent, how to create the locations the turrets would be able to go, and creating a walking path for the enemies to use. All of this was something I have never done before, and had a challenge of its own in order to accomplish it.
And Finally one of the hardest challenges I would face was learning how to create a PayPal integration. For this I would have to read the provided PayPal documentation, learn to understand the basics of “Curl”, “JSON”, and how to convert those to C# and from C#. To be honest I had to ask for some help on this and will be needing to work on it more in the future. I also learned to use some of Unity’s really cool performance tools like the “Profiler” and how we can find exact instances in our game that are creating garbage collection or huge memory draws. This is supper important to do so we don’t create something that will crash a users computer. And to put it all together here are a couple of videos of the game I created during this course.
Now that the game is in its final stages its time to focus on my goal of finding gainful employment in the programing industry. This week is all about career prep and job hunting. I will be looking to update my resume, linkedin, my website, and applying to as many jobs as I can find. I still have lots to learn but I feel confident in what I know and think its time to grow my knowledge with a like minded company. Happy Easter to everyone and Mahalo for taking the time to read!