In this developer log, I will be sharing the beginning of my experience with the Unity Create with Code course. This course takes you on a step-by-step journey into the world of Unity game development and C# scripting.
Player Control
The first unit of the course, called “Player Control,” had me create a driving game to learn how to apply physics, script a car to move using keyboard inputs, and apply these physics to allow the user to collide and knock over boxes.
The first lesson started by providing a folder of assets to create an environment, including the vehicle, boxes to collide with, a skybox, and the road to drive on. After setting up the environment, I began creating and applying my first script: a player controller.
The second lesson was the most important; it taught me how to move the car down the road at a constant speed and incorporate collisions with obstacles. Some key concepts and skills I learned included:
- Applying C# scripts to objects
- Using comments in my code
- Utilizing a Vector3
- Understanding the difference between Start and Update in scripts
- Applying Time.deltaTime
- Adding components such as Colliders and RigidBodies
The third lesson introduced the use of public variables to change elements of the game in real-time, creating smoother gameplay. This lesson replaced the previous static value of the “speed” in the code with a public float variable called “speed,” allowing me to adjust the variable while the game was running to optimize the speed to my liking.
Additionally, this lesson guided me in creating another script to have the camera follow the player and offset from the car’s position. I learned new concepts and skills such as declaring and initializing variables, understanding data types, and using access modifiers.
The fourth and final lesson taught me how to take full control of our car and drive it around the scene. The course shifted from moving the car forward at a constant speed to using the Input Manager system to update the car’s Vector3 with user inputs.
This involved allowing the user to control the car left/right while constantly accelerating. The lesson started by using horizontal movements to slide the vehicle left and right. Then later improving the code to rotate the vehicle left/right, providing semi-realistic movements.
The unit concluded by allowing the user to change the forward/backward speed of the vehicle using vertical inputs and cleaning up my hierarchy and code. The last lesson introduced the concept of grouping multiple objects into empty objects for organization.
After completing these four lessons, the final part of this unit is a challenge. Unity provided another asset pack, but this time, the goal is to program a plane simulator with obstacles. The challenge outcome included:
- The plane moves forward at a constant rate.
- The up/down arrows tilt the nose of the plane up and down.
- The camera follows along beside the plane as it flies.
To achieve this, I had to troubleshoot the code and resolve some bugs. Here’s a list of the issues I resolved to make the game function properly:
- Making the plane go forward
- Slowing the plane down to a manageable speed
- Making the plane tilt only if the user presses the up/down arrows
- Repositioning the camera so it’s beside the plane
- Making the camera follow the plane
Troubleshooting some of these issues was complex, but the lesson provided hints that pinpointed the exact issues with the code and suggested how to resolve them. I without a doubt enjoyed this unit; each step included a video and description on how to break down each function of the gameplay to create a solid prototype of the game.
As I reflect on this journey so far, I’ve gained valuable insights into game development and C# scripting. It’s clear that Unity Create with Code is an excellent resource for learning, providing a structured approach and in-depth understanding of how game development works. I’m excited about what lies ahead and can’t wait to apply the skills I’ve acquired. In the next part of my journey, I’ll be diving into the second unit of this course, called “Basic Gameplay.” I’m eager to start this new unit, tackle the challenges that come with it, and create even more exciting projects.