Learn C# Scripting for Unity

 



The motivation behind this article is to highlight the very basic point from where a new game developer should start

In game development you need to know that what developers are doing is to simulate the real world behaviour  to obtain the exactly same realistic game play world, and in order to have that artistic game we need to add some physics and forces components then control everything through scripting.

So how obviously that would happen ?


Firstly , the image above shows the monobehaviour interface, where we got two essential functions.In fact unity has a bunch of functions  each one has a specific role, here we got the two main used by unity.
 Start function is used to assign component called in unity and some piece of code that we want to execute only once the game is loaded for example set the position to (0,0,0) each time we start the game.
Update function is where all ingredients are cooked , means it is the main coding  part where we call other functions .
This is a simple example how unity generates script ,variables are  meant to be declared before the start function.
now to test if the code is executable , we add this line of code :

Debug.Log("hello unity");

You can write it in both functions  to see the differences I talked about and once you press play ,a message " hello unity" will display in the console section underneath the scene , this is as simple as it never been to get started .

Congrats now you learnt how to output a messages and some unity functions utilities 

What's next ?


- Destroying objects 
- Detecting mouse clicks
- Key inputs 
- Adding physics 
- Adding forces 
- Moving objects 
- Collision detection 
- Loading new level
- Display text and canvas
- Move player

We will go through all these and more, and for each title I 'll save the script in a Github repo so that anyone can use it .


Comments

Popular Posts