Viewers: in countries Watching now:
Interested in game making? Start in Unity—a game engine for mobile and desktop games and real-time simulations. Author Adam Crespi shows techniques used in game development with Unity and introduces the basics of scripting and game functionality. First, learn how to import models and textures, organize your project and hierarchies, and add terrain, water, and foliage. Next, Adam explores how to use lighting to bring the game to life, and add rendering, particles, and interactivity. The end result is a sample game with a lush environment, fully animated characters, and some basic interactive gameplay.
Although, you can mix and we often do see a mix. For example, on the first person controller. I'd highly recommend that you stay in one language. We can see that out first person controller has a C sharp and three Java's on it. I'll open up one of the scripts that comes with Unity, deactivate trigger and look a little bit at the syntax. And see why this is such a big deal. In the assets, I'll go under Standard Assets and then into Scripts. In scripts in general scripts, there's my activate trigger and drag rigid body.
I'll double-click on Activate Trigger to open it up. Unity has opened up that trigger script in MonoDevelop, and we can see it's a C sharp script by the extension .cs. What is says then, for example, right up at the top is using UnityEngine semi-colon. That's a perfect example of scripting syntax and how we need to keep this straight. It's declaring right off the bat that we are using the Unity engine and the line is ending with a semi-colon. In the next section down, there's a public class activate trigger which is a Mono behavior.
And within that those curly braces, a public enum and there's a mode available. What this basically lets us do is say, what kind of trigger would you like? An enum refers to a drop down list. We can see in here as well that the code is colored and hinted. And when we're writing code in MonoDevelop, we'll get hinting and auto completion of our different words to help us with the syntax. We need to make sure then that we are encasing in curly braces at the start and end, things that should be encapsulated. That we're ending our lines with semicolons.
That we're commenting out our lines, as well. The double slash for commenting a section, and the triple for commenting an entire line or paragraph. As we look further down, we can see that this is affecting public game objects, and allowing us to choose different ones. It’s also got cases in here, within the void do-activate trigger inside the curly braces, if different things are happening. For example, if the trigger count is zero and it's a repeat trigger, what happens if the object hits something? What happens to the behavior? Who's the game object target? If we're switching around, switching cases, what happens? Are we replacing and so on? What they've done here, for example, is to say, when we're activating the trigger, all of this goes on.
And sometimes there's even some other pieces. For example, in replace, if the source is no, do that. And we can see that the lines are tabbed in so that we get all of the different situations encapsulated in their braces. And lines are ended with a semicolon. Finally at the bottom, we can see that there's the end braces, ending all the different levels of encapsulation. Its important to make sure that the lines are ended with semicolons, and that were using the right kind of language.
For example, at the bottom it says casemode.deactivate. We'll see a lot of this, a dot syntax which is very common in all kinds of scripting languages. Really just saying, for the case mode Deactivate, do something. At the end of it, we've got a semicolon. And then finally, it's enclosed in the rest of those curly braces. At the bottom then, we're going to see now that we've declared all the stuff we're going to do, enter the trigger and do something. So all of what's up here inside those curly braces is what happens when we do activate the trigger.
I can't stress this one enough. You need to be as organized in your code as you are in your assets. So make sure that you're sticking with one language, and take the time to get to know the ins and outs of it. Make sure you've got consistent naming conventions and that you're commenting out your scripts as much as possible. It's very reasonable again that you'll work on this script, implement it and not touch it for six months. And then come back to it and say, what was I doing? And so if you got any kind of hints in there, that will be immensely helpful.
Its also very likely, especially if you are in a small team, lets say on a mobile game that you and three other people will be working together and sharing scripts freely. And you need to be able to hand off a script to somebody and have them be able to read it without saying, what was he thinking? But we may end up doing then is attaching scripts to blank game objects or other game objects with meshes associated. Doing things like the simple ones, activating doors. Or looking for things for score. We may even turn off and on gravity in a rigid body, so things don't fall until we contact them, and then they run away.
We can do all sorts of things here in the script, including making new custom materials, putting in new colors and new kinds of properties, such as rim shade or rim power to be able to get edge-lit surfaces. I want to encourage you to go as far as you can with your scripting. For this course, we're purposefully staying light on the scripting. Putting in the interactivity we can without getting too deep in the code. There's so much we can do with it that it's really a course on its own. So make sure you check back on lynda.com for courses on Unity scripting.
Microsoft has a tremendous amount of resources available for C-sharp, and will take you through all kinds of different cases. Everything from arrays and vectors to libraries and compiling. It's a terrific way to get deep in programming, and will be a very valuable addition to your game. So make sure you get in and watch the additional courses on scripting. And then look for ways to really enhance the game play using Unity and MonoDevelop.
There are currently no FAQs about Unity 4.3 Essential Training.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.