ObjectiveWhile learning Unity, beginners make a lot of common mistakes. I will show you those mistakes & explain how to avoid them.
New to Unity?
Don't know where to start your project from?
Confused about where your game is going?
Scripts not working properly?
Puzzled about your own code?
If your answer is "Yes" for any of these questions, you've come to the right place. Even if some of your answers are "No", have a look at this post. I'm sure you'll get some helpful info from it.
Unity is a very convenient tool for multi-platform game development. The rules & principles are quite easy to understand to get started with Unity. However, some common mistakes made by beginners can slow down the progress & can raise questions like I mentioned above.
In this blog post, I'll try to explain how to avoid such mistakes.
1 Planning Is So Boring, I'll Start The Development FIRST
Yes I know, planning can be a boring process. But trust me, if you spend enough time in planning before jumping into development, it'll save you from a big headache in future.
What headache will come in future, you may ask?
Well, in some cases you may have to pause and look for some assets. Or You’ll get stuck up in a long loop of corrections or modifications afterwards.
In the worst case scenario, you'll have to start your project all over again. Why? Because things will be too messed for corrections.
Such distractions can eat up a big chunk from your precious time and may cause you to miss your deadline.
Believe me planning the most important part of your project. You should plan well before you start a project. The importance of planning increase if you are working with a team. This will save you a lot of time and resources.
To begin with, you need to prepare a Game Design Document.
"By failing to prepare, you are preparing to fail." - Benjamin Franklin
2 What Optimization? My Game Works Just Fine..!
Oh! You have a new Nexus 6P. All games you developed run like butter right?
But wait! How about me? I have a lower version of HTC with low processor and low everything! There is no way in hell your heavy weight game would run on my device.
My point is, If you want your game to work on all devices, you need to start optimizing it.
Okay. Optimization is necessary; I'll do it after I finish my game
- We are almost finished with our project. Now we need to re-scale some models for the sake of optimization. After that we have to re-arrange our whole scene because of that.
See how much time is wasted.
- We need to change some code in some script to solve a performance issue. Now we have to do some modifications in other two scripts.
Another example where our precious time is wasted.
If you have already been through such situations, you know how much time that can consume.
If you start working on the optimizations from the beginning, you won't have to face those troubles at the end.
We've started the Latest Optimization Initiative for Unity Games blog series for you. This will make optimizations easy as never been before. Hurry & get there to learn how you can optimize your game.
3 What Now? No Errors In The Editor, Nothing Wrong With The Code. Then Why The Heck Is My Game Not Working Properly?
This will happen sometimes in your initial days with Unity. You'll get errors or warnings. To solve it you'll check your code multiple times, and still won’t be able to find where the culprit is.
At times like this, my seniors would advise me "you should check Unity editor to find the solution."
You can check the inspector for false assignments. Or You may have done something wrong in the hierarchy. Check your editor window thoroughly.
4 Physics Is Getting Weird..! What Should I Do?
There are a number of small things that can make your physics look unusual.
If you find your game physics acting strange:
- At first, check your code for misspelt methods. For instance, if you've written OnColisionEnter() instead of OnCollisionEnter() that won't work.
- Be careful with 2D & 3D also. While working with 2D, don't forget to use "2D" in your code. like OnCollisionEnter2D(), RigidBody2D. If you miss the 2D part, your code won't work. This mistake will not generate any errors or warnings either.
- If you still find your physics working weird, check the scaling of your GameObject. Try to maintain the scale 1:1:1 if possible.
- When a GameObject has RigidBody component and you want to move it, do not use the transform values but apply forces (like velocity) instead. You'll get your desired results.
5 Unity Works Fine As It Is. Why Should I Extend It?
You may think that Unity editor is quite sufficient for level design & game testing so there's no need to make any changes.
Believe me that's a wrong assumption.
Have a look at various built-in functions & tools. Explore all settings & other aspects that Unity provides. Also don't forget to visit Unity Asset Store & plugins available for Unity.
I'm sure you'll find many useful things starting from models & animations to scripts & complete projects there to make your development faster.
These are the links for you to know more about plugins & Asset Store:
You can also launch Asset Store from within the Unity Editor (Window → Asset Store).
I GOT THAT ALL!, I WON'T MAKE SUCH MISTAKES IN FUTURE..!
OH YES! YOU ARE A SAVIOUR..!!
I hope this thought has crossed your mind after reading this post.
Now, before I finish up let me give you some short tips:
- Develop a habit to save your scenes in every 15-20 minutes. So that when Unity crashes or your PC gets shut down because of any natural disaster or any alien invasion;-P, you don't have to repeat the tedious re-arrangement of your scene again.
- Put some “cheats” in your game while testing. Yes! Cheats (like we use in GTA games). This will help you to test your game faster. For example, you can make your player indestructible or get unlimited ammunition.
Always compare your script name with the class name. If you want to rename a script, do not forget to rename the class name too.Your script won't work at all, unless both names are the same. You’ll get a type mismatch error or a behavior missing warning. (Another case where you should not ignore warnings)
Here's a shortcut for you:
- In case you don't want to remember this, just use rename command (F2) & you're good to go. This works for all names (methods/variables).
If you still have any doubts related to this post, share your thoughts in comments section below. I'll get back to you ASAP.
Learning Unity sounds fun, right? Why not check out our other Unity Tutorials?
An Addictive Gamer turned into a Professional Game Developer. I work with Unity Engine. Part of TheAppGuruz Team. Ready to take on Challenging Games & increase my knowledge about Game Development.