Unity Common Beginner Mistakes
- Lizard King
- Aug 27, 2022
- 2 min read
As a Unity game developer I have encountered many errors and mistakes in my career. Some of them were really edgy and I wanted to punch the screen (Which is not a good idea).
Instead going crazy in your rookie stage of Unity development I don't want you to loose your will or motivation so I made a list of bunch of these mistakes. Keep these things in mind so you shall not waste your time.
1- Renaming C# script after creating it - a different class and script name issue.
2- When adding a new tag from the inspector on the new game object, Unity creates a new tag but does not automatically add it. You have to reopen the inspector again to add that that
3- If you name your script somethinging like Input. cs and you get some strange stuff happening.
4- Making changes in Play Mode only to have them all undone.
You can set a colour tint so you know when you’re in play mode so you don’t lose changes thinking you’re not in play mode.
5- Finding out that async code by default keeps running when you stop play mode.
6- Lots of performance difficulties, mostly resolved by setting things to static correctly, generating lightmaps appropriately, and using simpler shaders for everything instead of the default.
7- Adding several copies of a script to the scene and then forgetting about one of them. So you get a lot of posts about "the error is saying that the object isn't assigned, but it is assigned",
because they're looking at the wrong copy of the script. Teach them that clicking an error message pings the error object, and you'll save a lot of headache.
8- Really crap performance due to putting Debug.Log in a loop. Debug.Log isn't that slow, but it's a lot slower than most other things you do in code.
It's completely fine to have a loop that does math run a million times, but if you have a loop that Debug.Logs a thousand times, it will lag things to hell.
9- Rotations are Quaternions! This is the case in every game engine, but since the inspector for Transforms shows euler angles,
new people expect that doing rotation.x += 90 rotates something 90 degrees on the x-axis.
10- Some code you might want to use at runtime is editor-only! I remember being new and building a whole system around some UnityEditor API
just to end up having to scrap it because it doesn't build. Teach them to build pretty regularly to see that their game can run outside the editor.
These are the most common things that comes to my mind. In this world of errors if you know another stupid mistakes/errors please let us know!
Comments