- Home /
Learning Scripting (Next Step)
I've been learning scripting, and I feel that I have a pretty good knowledge of scripting. I know things like :
Variable Types
Different Functions and Purposes
GUI Functions, including Working Buttons
HUD - Health Bar, Energy Bar, Ammo, Speed
Instantiating
Accessing Rigidbodies (Just a little)
Accessing Variables from other scripts
Basic Script Optimization
If, Else If, Else...
And more around this level......
Somethings I know I don't know about are :
Raycasting
Arrays (I have basic understanding)
Loops
Enums
With that, I can write scripts such as :
Shooting
Ammo
Movement
Bullet Scripts (Audio, Damage, Colliders)
Damage Recievers
HUD
Quitting, Pausing, & Loading Levels
More...
So I have all this knowledge... what's next? Are there any tutorials for learning advanced or even intermediate scripting? I've looked at plenty of beginner tutorials, I've read books, I've gone around the internet, and I haven't found a tutorials that can cover many subjects and help me learn. At this point, what I'm doing is using Unity Answers to help me solve my problems, and I start to learn how to do things that way. I've gone through the Unity Manuals. What should I learn next, and how should I approach learning it? This question has bothered me for a long time, and I need to make my scripts more efficient, have improved capabilities, and even have functions that I couldn't put in my scripts before. If you would like me to post up one of my scripts so you can gain a better understanding of my understanding of UnityScript, then ask. Thanks.
I'd say now you should try actually making a game! Try co$$anonymous$$g up with a game that you want to make, and apply the skills you've learned!
I must say, you're doing things in the right order- as opposed to most of the people who post here, who try to make a game without first knowing the basics...
Loops and arrays should definitely be next on your "to learn" list - without knowing those two properly you will write horrible and time-consu$$anonymous$$g constructs that are completely unnecessary ;)
I'm in the process of making a game, but there are some features I don't know how to do, such as counting the number of enemies the player has killed, or locking on to a certain target. For example, I'm flying and I want to lock on to a target and fire a ho$$anonymous$$g missile. Well I have a basic ho$$anonymous$$g missile script, but it will only lock on to a target with a tag, not a specific target. I'm trying to get a better of understanding so maybe I can figure out that question myself before using Unity Answers.
Answer by Tseng · Nov 03, 2011 at 06:56 PM
Yea... one thing you haven't listed is OOP programming. It's not only important to know how to use the API, but also to know the basics of OOP.
Interfaces
Polymorphism (deriving classes)
Singleton pattern (quite important in many game projects, to have a global instance which can be accessed without having to using GameObject.Find
Since you haven't specifically named which of the 3 languages you're using to learn Unity development, it's hard to give exact hints.
This below is more or less C# specific (which is much more powerful language to do Unity3D development than UnityScript or Boo)
Generics (i.e. using ArrayList or learning how to write your own generic methods & classes)
Events & delegates (delegates C# only)
Lambda methods (i.e. myClassArray.Sort((o1, o2) => o1.myVariable.CompareTo(o2.myVariable));)
LINQ
Then there are of course other, non language specific stuff, but still usefull:
Serialization (putting values from classes into a string, xml or binary file and reading it back, useful for loading/saving games)
And last but not least (something you can't learn from a tutorial): Experience. You will only learn to do something right by trying it out and then (days or months later) you'll notice the flaws of your design and improve it next time. That's something you can't learn by reading books etc., that's something you have to experience yourself.
I'm using Java specifically, as I've only started learning scripting about 3 months ago, and I heard that Java is the easiest to learn. Should I learn C# ins$$anonymous$$d? Do yo know of any tutorials that covers any of that.
C# is closer to Java than Javascript is. Learn C#, its more powerful.
Apparently JavaScript was meant - it's amazing how many people mix up Java and JavaScript.
@Tseng: A complete side-note, but it's very rare that you actually need singletons. Usually you just want to access one global instance, while singletons are for the rare case that you can't have more than one instance of it around. Some more details here.
Sigh... had posted a big comment why singletons are useful if you know how to handle them... but it got lost.
Whatever, Singletons are very useful, for example for the general game controller (which handles everything from current level, pause, etc), for scores (where you can access your score class from everywhere w/o having to search, check and instantiate it if it doesn't exist (specifically if you start a given level in the Editor, without going the typical process of mainmenu > select/load level) or if you make a Pool class which recycles your objects.
All of them can easily be accessed like
Score.Instance.CurrentScore += 100;
The Instance Property will check if it was already instantiated and instantiate it if necessary. No Variable for "Score" to hold, no checks, no lookups. Easy and clean.
With that you basically have one lazily created global variable (doesn't really matter wether you access it as Foo.Instance
or Globals.Foo
), not a need to enforce that you can only ever have one instance (i.e. private constructor etc.). :)
Answer by wccrawford · Nov 03, 2011 at 01:59 PM
You've gone beyond all the Unity-specific tutorials now. You should start studying more generic programming arts such as Design Patterns, and apply them to UnityScript.
Other than that, just practice, practice, practice. That's how every programmer gets better at what they do... That, or find a mentor.
If there are any local Unity groups, joining them can help improve your skills as well.