So I’ve been using Unity for a while now, and I have made a couple basic games. I took a large break from Unity due to lack of motivation.
My lack of motivation comes from not being able to write my own code, and make my ideas for games possible. I am very familiar with the engine itself, and I know/understand code terms (the basics at least) such as:
-floats
-loops
-classes
-rigidbody’s
Along with some other stuff.
I just can’t seem to write my own original code, and just end up browsing YouTube tutorials or looking at forums then copying and pasting other peoples code into my game.
Tutorials are a GREAT idea. Tutorials should be used this way:
Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That’s how software engineering works. Every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly. Fortunately this is the easiest part to get right. Be a robot. Don’t make any mistakes. BE PERFECT IN EVERYTHING YOU DO HERE.
If you get any errors, learn how to read the error code and fix it. Google is your friend here. Do NOT continue until you fix the error. The error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.
Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.
Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost.
Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there’s an error, you will NEVER be the first guy to find it.
Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!
And here’s a pile of great tutorials. If you “work through” the following tutorials doing EVERYTHING that I note above, you will have grasped how to write your own code:
It turns out that programming a game is just as difficult as programming a “real” computer program – it’s just not something you can pick up by seeing examples. There are some concepts that it really helps to have the theory explained. For example float and ints are both numbers – why use one over the other? And floats, ints and classes are types and there are consistent rules for using them. And all loops are really while loops – for’s, foreach and do-while’s are merely shortcut versions; that results in a lot less memorization and worrying about what loop you need to use.
Find a C# textbook to at least skim. Mine’s at taxesforcatses-dot-com/TOC.shtml. But your library should have a decent one. But here’s the thing, which is a reverse of the 1st thing I wrote: if you learn to be a game programmer, you’re also learning to be a real programmer. You know learning to be a real programmer will take time. If you enjoy it, it will be fine. But if you just want to learn it so you can make games, it’s going to be long and painful.
Floats are a number with a decimal place. Computers have different number types for different jobs. The reasons become clearer over time, but floats are your default choice for a number that needs fine accuracy.
Loops. Computers have to repeat a list of instructions. And you know if you’re a a carpenter, doing a lot of chairs then that’s a loop going on. Repeated instructions cos computers are dumb as rocks, actually.
Classes are just how we shape our code in regular Unity. You put your game in one, you use one to hold a list of bullets, so on. It’s basically a bit of of program, that has data and some loops or functions and stuff. Don’t sweat it just do a lot of tuts - it will become clear. They are containers for data and code.
Rigidbodies are just 1 part of a 2 part puzzle. The rigidbody is how a collider will behave in physics. So it controls the weight and feel and movements, all the physics stuff. The body. The collider is the shape of that. It’s simpler than you imagine.
The other stuff is you doing tuts that interest you. Really it’s only a mystery because you do so little of it really. You have to do this almost daily if you care to get a handle on it, but after a while you don’t need to learn so much and can be chill.
I’ve found so many video tutorials have steps 2a, 2b, 2c … which go something like:
2a) realize the author never explained why they wrote it the way they did; they may have said “this line checks for keypresses” but never explained how it checks, 2b) realize another tutorial does it differently and also doesn’t say why, and there’s no way you’ll hear them explain to each other which way is for what, 2c) after painstaking look-ups, realize one step is actually using a very complicated trick which isn’t needed here, but they just wanted to sneak it in, 2d) same as 2c except realizing they did 2 similar things in different ways – no reason, they just wanted to show you both ways, 2e) after not finding something, realize it’s not basic C# – it’s a Unity function (which they didn’t tell you), 2f) realize each step is actually several smaller steps which they definitely don’t explain… .