Complete C# (sharp) beginner - Any tips on learning?

Sorry about this post being unbelievably general.

I’m currently reading ‘Unity 3.x Game Development Essentials’ by Will Goldstone. It’s real good and all, but I’ve tried to learning programming and scripting in the past, and I’m still getting stuck. I can copy the scripts from the book and they’ll work, but I find that I still don’t really understand what’s going on. I read the descriptions, but like in other books I’ve read, they seem to assume you have some prior knowledge of “coding” in general. For example;

“Functions or methods as they are also known, most often start with the term void in C#. This is the function’s return type, which is the kind of data a function may result in. As most functions are simply there to carry out instructions rather than return information, often you will see void at the beginning of their declaration, which simply means that a certain type of data will not be returned.”

I know this is early in the book, and I can just continue on after it with little effect, but to be honest I don’t totally understand it. I’m posting this because I think that if I don’t totally understand everything this early on, later when it get’s more complicated, I will just get lost, and also never actually memorise anything I can use later. I mean, saying something like a void is also known as a function or method is just confusing to me. And “This is the function’s return type”, returning from where to what? What, how, when…

Scripting in C#, or scripting in general, is very abstract to me. In short, I’m a dumbass, and I was wondering if there’s any kinds of miraculous visual guides out there that could help me? I mean, the bit in the book that says stuff about;

Dog.breed;
Dog.fetchStick(25);

That analogy kinda stuff did help a little, but still, I need pictures and stuff, or something. Or am I talking nonsense? Should I just keep going on and it will just start to all fall into place?

Thanks for your time.

Yeah, that book is cool for teach Unity basics, but not for teaching programming. For programming, you need something like C# for Dummies, but keep in mind that programming isn’t for everyone, and it requires you to sit down and really read and think hard and do the actual problems.

Ew - never buy a for Dummies book. :slight_smile:

The WRox Professional series of books on C# and .NET are hugely informative IMHO.

I suggested the Dummies book as a last resort; from the reviews on amazon, it would seem to work more for the layman while the Wrox books are generally for people already in the field.

Programming is complicated and simple at the same time. Best way start is to mess about with logic without concerning yourself too much about fancy bits. First important thing to learn about are variables, they hold information that you will use throughout a game/piece of software, next thing functions, how to take those bits of data - numbers, strings, arrays and to create something out of them. Start really simply, 1 scene just creating random strings / numbers from set data maybe.No 3D models / graphics, simply scripts doing things. Use the debug.log a lot, and learn how to check on what is happening within the program.

I started with UnityScript, with a bit of prior knowledge about programming, two years ago. Now I program in Objective-C for job and coming back to Unity with C#. I’d say stick with C#, the logic will be the same no matter what language you use - although in Unity the Editor features make it different from using theoretical objects.

Programming at first is abstract. The more you read and more importantly try to program, the more it will sink in. I never used to return data when I created my two games with unity - it wasn’t that obvious to me and I used workarounds anyway. The more you immerse yourself the more you’ll get out of it.

For instance with your example:

Dog.breed

Dog can be a class / blueprint for a dog type so you might have created a lot of Dog objects that share the same property - breed.

In a game context, it could be simply checking what sort of Dog it is. So you can create a way of deciding about it.

if (Dog.breed == alsation){
Log(@“its pretty big”);
}

if (Dog.breed == chihuaha){
Log(@“its really small”);
}

Programming is like making decisions and thinking about if a certain condition meets a requirement to make another decision.

To be honest when i first started doing small app’s i used xerox.net very simple tuts for cpp from there i went on to doing 2 courses 1 in interactive gaming and the other bs in computer science then from there worked as a intermediate programmer then got made redundant lol. so now im working for my self ( broke looking for work ). i recommend a course to teach you the fundamentals and basics that you will need to get a head in your career if this is truly your passion and what you want to do.

Thanks to all of you for your advice! If anyone else has something to say though, feel free to reply. I don’t want to sound like I’m fine now and closing the topic.

Thanks dom_g, I read your mssg, and I will read it again tomorrow, when I can understand it better (it’s half midnight for me now).

For a very basic introduction to coding in general you can take one of my online classes:

Also you can look in the teaching section:
http://forum.unity3d.com/forums/23-Teaching

For coding resources:
http://forum.unity3d.com/threads/113937-Getting-Started-with-Coding-for-Unity

As it happens, I’m going through the same book, though I’m a bit further on (a bit better than half way through at this point). My first piece of advice, would be not to sweat it too much if you don’t understand everything yet. In the early part of the book, while you’re going through the prototype phase, things aren’t as well explained for a novice as they might be. This concerned me as well, as I’m a complete C# noob myself. A bit further on, the explanations get more in depth and are generally easier to follow. Also, just by virtue of writing some of the scripts, you’ll become more familiar with C# syntax and structure, which also tends to make things easier.

As far as the specific passage you posted, the best way to think about it for me is this: There are two very important building blocks to writing code (there are more than two, but these two are probably the most fundamental). Variables, and functions. A variable is made up of two parts, a data type, such as “Int” for integer, “float” for floating point (any number that has a decimal in it), or “GameObject” which would be, well, a 3d object in the game. So the first part of the variable just tells Unity what type of data this variable should contain. The second part is the name of the variable. The name is completely arbitrary, and is up to you what you want to call it. However, it’s a good idea to use some standard conventions as it makes the names and how you spelled/capitalized them easier to remember. Once you “declare” a variable (basically just write it’s two parts, the data type and a name you give it) it is then usable within your script. So a complete variable might be

GameObject newEnemy;

or

float bombTimer;

Variables can have an initial value set for them when declare them or not, that’s up to you and weather it suits the purposes of your script to do so. So if we declared an initial value for the second variable example, you might use:

float bombTimer = 3.0f;

In this case we’ve set the initial value of the “bombTimer” variable to 3.0.

Functions usually make use of variables to actually do things. They might return a certain data type (such as our examples above), which might be used for something somewhere else in the script, or more frequently they just carry out sets of instructions. In the case where they’re just carrying out instructions rather than returning data, they would start with “void,” as they have no data type that needs to be returned.

Hope this helped, if you want we can PM so we don’t irritate the real programmers on the board with our complete noob discussion. Going through the same book at the same time might be helpful to both of us.

Cheers!

1 Like

Oh, also, I just found the thread on this book:

http://forum.unity3d.com/threads/27361-Unity-Game-Development-Essentials

So that might be a better place for both of us to post questions on this book in the future.

Cheers!

I’m going to go against the grain. You will never become a good C# programmer if you think of it as a Unity tool, you might be good at C# as it applies to Unity, but you’ll probably overlook a ton of great things you can do in and out of Unity.

Learn Unity, but on a parallel track, play around with raw C# and learn what you can do. There is much you can do to extend Unity, but if you only know what Unity can do, how could you extend it?

Sound advice JRavey. I’m working through this book for the time being. After this, I’ll be doing one of two things. Time, and registration permitting, I’ll take the C# course at the local CC when the fall semester starts. It’s offered as an online course usually, so that should work around my schedule. If I can’t get the course, I’ll pick up the Head First C# book and use that. Always been part of the plan for me, because your right, just learning C# within the context of Unity is unnecessarily narrow.

I found 3D Buzz’s Hyperion tutorial a fantastic way of getting into C#. Although it’s in the ‘XNA’ section, it only uses C# and the .NET framework. At the end you’ll have a complete text adventure that runes from the console and you will have learned a lot about how to use C# (because the 3D Buzz guys are really good at putting things into context and making them clear and understandable even for a complete beginner) and of course you’ll have ‘game design’ on the brain. Then 3D Buzz has some really useful Unity3D tutorials and their scripting ones all use C#.

Maybe watch 3D Buzz tutorials in this order:
Hyperion C#
Unity3D 3rd Person Character Controller
Unity3D 3rd Person Platformer

This is all I used to get started.

1 Like

Thanks for the tips! I’ll check those out. And I have game design on the brain anyway.

Cheers!

The simplest thing you can do is google the terms that you do not understand – something like method + c#. You are bound to find definitions that suit your way of understanding material :slight_smile:

http://www.youtube.com/watch?v=YYqzz1dy3Ak -BurgZergArcade.He has over 250 videos from baisic stuff to pretty advanced

Good luck!

1 Like

Good stuff. Thanks for all the advice, you lot. I have a lot more of that book to get through.