Hi, so I am very new to scripting, and I have a question that might be stupid to those experienced in scripting. What exactly is the difference between if and for statements? I have a scripting class that showed me how to use both, but I’m still confused about which one is used for what. If someone could explain it to me, that’d be great.
for repeats code until a condition is satisfied, can be functionally identical to while loops.
if statements are conditionals, they will create branching paths that the code will go down.
Also worth noting is that all this basic stuff is covered in the C# docs:
It turns out that scripting in Unity is just regular computer programming, so any decent intro-to-programming book will cover IF’s, FOR’s and a bunch of other basic stuff. I’d love to recommend a good one, but the best I can do is mine, at Basic Programming (it’s either in a PDF, or a big HTML, or small HTML chunks – all are the same).
The main problem with it is when other things I’ve written on this site have made you angry. Then it can magically become full of typos and giant run-on sentences.