Hi Boris,
Good job on spotting and solving the problem yourself.
As a general rule (with exceptions): Classnames start with a capital letter. Variables start with a minuscule letter. The compiler does not care as long as the spelling is correct. It’s just a naming convention created by us humans to make the code more readable for us.
If you write a class, let’s say MyClass, and declare a variable of that type, you do this:
MyClass myClass;
MyClass anotherClass;
MyClass myObject;
MyClass abc;
In the UnityEngine, there is a variable/property named gameObject
. Since Unity, fortunately, follows the most common C# naming convention, we can immediately see that this is a variable/property. And, according to this logic, GameObject is the class.
One more thing: A class name never stands for itself. You will never find a random GameObject;
or MyClass;
in anybody’s valid code. If you see a lonely name, it’s usually a variable/property.
Two examples:
GameObject player = gameObject;
GameObject player2 = GameObject.Find("Player");
I hope this helped.