0
Unity for beginners all the thing u need to know
Hello fellow programmer's I started unity as my first game developing software I know u can use java script or c # I get use to c# so can u guys provide some commands or rules that i need to know and I am try to make 2d so it would be great if was on that.
2 odpowiedzi
+ 2
C# is the same here, only you won't have a main method. Unity will be dealing with the main for you.
These are things you'll need to know for Unity:
All you need for C# is already on SoloLearn.
* You must have some sort of lighting on the scene, otherwise everything will be black. By default there should be a "directional Light" object in the scene.
* void Start(){} runs once, before the Update, when the game is loaded.
* void Update(){} is constantly run, every frame
* Extend MonoBehaviour if you want to attach a script to an object
* Only make the scope of a variable Global if you always need to keep track of it, and/or will be using it in many methods.
Do not make something global just because it is in the "Update" method.
* On par with what I said above ^, try not to fall for performance heavy mistakes. Unity is really fine for performance, it's mostly the programmer at fault.
Example/
NEVER use GameObject.Find(String) constantly. (Such as, in the Update method). This is a slow process. I honestly try to never use it, unless absolutely mandatory. One case could be if the variable must be static, so in the awake() method I do a null check and initialize the variable by finding the object.
ex/
if (myVar == null)
myVar = GameObject.Find("blahblah");
I still try to avoid using this.
Generally, if something isn't static you can just serialize it.
+ 2
~ Important ~
* In order for collision events to occur, one object needs a rigidbody
If you are brand new to Unity, you may not know what I mean by this. But it will still spare you time when the trouble comes.
* Asset store can have cool stuff if you are new