Unity and C# : Learn Scripting

Scripting is an essential ingredient in all games. Even the simplest game will need scripts to respond to input from the player and arrange for events in the gameplay to happen when they should.

-Unity3D

Everything in unity3D is a GameObject. We first start building a game by setting the sprites (2D) / 3D models in their respective positions.In a 2D game setup,Players and enemies will be in the foreground and other elements which we don’t interact much will be in the background.Once this is done,you have some non-moving static GameObjects.Its just like a photo rather than a video which you enjoy watching.

To make these Gameobjects move, to be more precise move according to your inputs/instructions.Scripting is very much required.

Scripting

 

Unity supports three programming languages natively:

  • C# (pronounced C-sharp), an industry-standard language similar to Java or C++;
  • UnityScript, a language designed specifically for use with Unity and modelled after JavaScript;
  • Boo, a .NET language with similar syntax to Python.

 Which one should I learn and use ?

Huff!! a very tough question to answer.There’s always a missing clarity on this.To be diplomatic i can answer like this

Every Language has its own pros and cons.

But i won’t….I support C# because

  • Its a strongly-typed,type-safe language.
  • Purely based on Object-Oriented programming concepts.
  • Above all, i am comfortable with C# as my background is .NET.

Note : Boo,as of now is completely out of the race.

Whenever i have this question of ,i read this

I would say it depends very much on your past experience. If your background is in C++ or Java, you will likely feel most at home in C# – however if you’re experienced with dynamically typed languages such as JavaScript / Basic or PHP, chances are you will prefer JavaScript.

If you have no previous experience with programming – JavaScript might be an easier introduction – given that you do not need to worry about types and casting.

Do note that writing JavaScript in Unity is not the same as writing it for web browsers (which is why it is popularly nicknamed UnityScript in the community). You should check out the tutorials to familiarise yourself with it if this is the route you’re going to take.

If you are planning to work with other programmers on a Unity project, I very much recommend that you decide from the beginning to work in the same language. While it is completely possible to combine scripts written in multiple languages into one project, you will very likely at some point run into issues due to the nature of the task of compiling and linking multiple languages.

Finally do notice that all documentation and tutorials for Unity are currently written in JavaScript and of the three available languages for Unity, only C# examples are given in the .NET documentation (since you are working with mono, you have full access to the mono port of the .NET library).

Learning scripting is not a one day task.Scripting is a skill that takes some time and effort to learn.

Here are some links to start with

Video Tutorials

Courtesy : Unity3D docs and Forums

Advertisements

3 thoughts on “Unity and C# : Learn Scripting

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s