In this Unity video tutorial we’ll be going over some of the basics of scripting in Unity. Building on what was learned from the Getting Started Videos.
First I’ll talk a bit about the differences between the three available ‘flavors’ of UnityScript (JavaScript, C# and Boo), and will then proceed to write two basic JavaScript and C# scripts to move a cube around.


first to comment
Good job on the tutorial.
How much better or worse is it to use boo rather than java or c#? And what would be the advantages of any of those ober the other?
(If it’s in the video, sorry, my bandwidth is out and cant download right now. I will though as soon as it (bandwidth) picks back up)
thanks,
Sasbian
ober = over
and i did get to see a little of the tutorial though.
I’d give you a cookie for being first, but you said Java instead of JavaScript, which is a … touchy subject, to some.
*eats cookie himself*
Anyway, both questions are answered in a bit of detail in the video, but in short, no language is superior to the other, with the exception of some advanced stuff being only possible in C# (I.e.: reflection, C/C++/Objective-C calling). That said though, if you’re fairly new to programming in general I would recommend -against- using Boo. Reason being is that very few people actually use it, and thus most code examples, snippets, questions and answers are in JS and/ or C#. (The Unity documentation always provides examples for all 3 languages though.)
However, if you feel comfortable using Boo and you have no trouble translating “var target:Transform” to “public target as Transform”, then of course feel free to use it.
I should probably also point out that any combination languages can be used throughout your project and even on the same objects. Since it’s all just a syntaxical flavor of the same underlying language (UnityScript), they can still all communicate with each other, calling functions, getting and setting variables, etc.
Hope you’ll enjoy the tutorial!
-Patrick
thank you. that was very helpful. reflection is one of the things that I want to do in my current project. I am new to programming in general so I think that I will start off with learning a bit of c# and keeping an eye on boo (for some reason It seems easer to me). And that was a very good answer to the question.
thanks,
Sasbian
What is reflection? A programming term or the actually reflecting something in the game?
Oh, Jeremy raises a good point! I meant the programming term reflection. From Wikipedia: “In computer science, reflection is the process by which a computer program can observe (do type introspection) and modify its own structure and behavior at runtime.”.
ok … I took that as actual reflection, lol. Thanks for clearing that up for me.
thanks
sasbian
Can you explain the differences in using – + = -= += == && etc? Or know of a good reference for those? Not sure why it’s not “transform.position.x + speed”.
Other than that I thought it was a great tutorial. I should have watched this first! lol
Jeremy
Hey Jeremy,
Sure thing! They’re called operators, and here’s a quick overview of what they do: http://pastebin.com/LUqWDjgu
Hope this helped!
-Patrick
That clarifies things up a bit. I’ll do some more research because I still don’t understand the difference of + versus += . Thanks for the link and the name!
Jeremy
Ah sorry, I could’ve been a bit clearer on that. Basically it comes down to this:
+ is always used in a syntax similar to “x = a + b”, where the result of a+b is stored in another variable.
+= is used to add something to a variable and store the result in that same variable. For example “x += a”. This is the same as saying “x = x + a”.
Think of it this way: += means “add to, and assign the result to”. =)
-Patrick
Now THAT is a great explanation. Thank you sir!
Jeremy
Wow, nice tutorial, Patrick! But I got one questions:
1. I see you have a mac and your using monodevelop, and I was wondering how do you open it on your mac.
Thanks Patrick, for this nice tutorial!
P.S Here’s a VERY good link about scripting for noobs!: http://www.unityscript.com/lessons1/basics.php
-Jnick
Hey patrick!! As im new to the unity world im trying to build a simple hover craft racing.
Game ive got the models of crafts an a place to race i need help with writing a script to make it come alive. For now a simple forward back left right an idle. Or should i say hover idling will do please can u get back to me on this. Sad face. Progression is a must gamer for life lool. Thanks
I believe the making a game in 30 minutes on Unity Cookie will be your best option
Also we will be taking a look at using mecanim which would allow you to do some more advanced movements as well.
-Alex