Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In Unity, scripting provides a powerful tool set to extend and enhance the functionality of the game. We can even extend and enhance the functionality of Unity itself. And it supports three different scripting languages plus a shader language to do so. To attach a script to a game object, like we did with the first person controller, we can simply drag it in as a component. I'll put a new blank script on one of my objects to start out. For example, I'll pick the master building and add a component. In the Components, I'll choose New Script.
MonoDevelop is a powerful scripting program that ships with unity and supports multiple languages. It also supports code hinting and syntax coloring. It will help you along as much as it can and really let you get in and get the best out of your scripting. What this says, for example now, is that when the game starts, function start, do something. In this case nothing. And then update every frame, do something and again, nothing. We're ready to add pieces into this script and it's that simple to attach scripts to an object.
We can either make scripts by choosing new components or we can make a new script right in the assets window and then drag it onto an object. I'll close this script sink in MonoDevelop and come back and look at creating a new script. I'll right click in the Assets window, and choose Create. And here's a C sharp. I'll name this C sharp, rise. And there's that C sharp script selected in the inspector, showing, well, what's going on so far. In this case, void start, nothing, and void update, nothing.
When it starts out the game, initializes, do something and once per frame, do something. That's the basics of it. We can make a script to do just about anything we'd like. Anything from culling animations through extending functionality when a character collides with something If you've used a first-person controller, you're already using scripts. And it's that simple to get them implemented. There's no limit to what you can do with the script. So get in and explore. And start to make scripts that enhance the functionality of your game.
Get unlimited access to all courses for just $25/month.Become a member
107 Video lessons · 31700 Viewers
90 Video lessons · 21972 Viewers
78 Video lessons · 8047 Viewers
83 Video lessons · 7754 Viewers