Unity Lab #2: Write C# Code for Unity
Unity isn’t just a powerful, cross-platform engine and editor for building 2D and 3D games and simulations. It’s also a great way to get practice writing C# code.
In the last Unity Lab, you learned how to navigate around Unity and your 3D space, and started to create and explore GameObjects. Now it’s time to write some code to take control of your GameObjects. The whole goal of that lab was to get you oriented in the Unity editor (and give you an easy way to remind yourself of how to navigate around it if you need it).
In this Unity Lab, you’ll start writing code to control your GameObjects. You’ll write C# code to explore concepts you’ll use in the rest of the Unity Labs, starting with adding a method that rotates the 8 Ball GameObject that you created in the last Unity Lab. You’ll also start using the Visual Studio debugger with Unity to sleuth out problems in your games.
C# scripts add behavior to your GameObjects
Now that you can add a GameObject to your scene, you need a way to make it, well, do stuff. That’s where your C# skills come in. Unity uses C# scripts to define the behavior of everything in the game.
This Unity Lab will introduce tools that you’ll use to work with C# and Unity. You’re going to build a simple “game” that’s really just a little bit of visual eye candy: you’ll make your 8 ball fly around the scene. Start by going to Unity Hub and opening the same project that you created in the first Unity Lab.
Here’s what ...
Get Head First C#, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.