Struggling with C# in Unity, any advice?

When I started the Unity course I had no experience with any sort of programming. The most I’d ever done was tweak .ini files for games and messed with existing HTML code a bit, mainly I just broke things.

Rather shortly into the course I realized that I was probably going to need to learn the very basics of C# so I paused the Unity course and did Bob Tabors C# for Absolute Beginners and that helped me at least grasp what Ben and Brice were showing. But I’m still struggling a little too often and right now I’ve hit a wall, it’s starting to to make me doubt if I’m ever going to understand how to program.

Currently I’m stuck on lecture 212 in Bowling Master, which has us finishing a script using TDD to keep score of the game. TDD by itself is quit the thing to wrap your head around but that on top of the challenge to finish the script using TDD has me lost. I just don’t understand where and how to use somethings, take an array for example, I understand what an array is and the basics of how one works but I’m limited in the ways I know how to use it.

I’m currently debating on if I should have a read through a C# book(C# Yellow Book) or press on and watch the video and then try it afterwards. I’m not giving up on this but I feel like at this point in the course I should probably be able to float instead of drowning all the time.

Did anyone else ever hit a wall like this? What did you do to get over it? If you’ve got any advice I’d love to hear it, if I manage to get past this I’m sure it will be the first of many walls.

1 Like

Hang in there @Hellsrage

Six months ago I was in your exact position. I had no prior experience with code or game/app development. I was working in agriculture! This was a whole new world to me.

I struggled through many sections and felt like I was getting left behind. When I hit a wall, I would re-watch the videos (sometimes three or four times), go through the Unity Docs, search on Google, then tackle their challenges again. Some challenges I just couldn’t do, and ended up moving on. Don’t worry if you can’t do them all. TDD is still something I’ve put aside for another day to learn about.

Once I completed the course and started making games for myself, did I realise just how much I had learnt. I had my first game prototyped in no time. It took a while for me to get comfortable with C#, but almost always an answer can be found on Google for a problem you are trying to solve.

I haven’t read any C# books, so I can’t give any advise there. For me to get through, I just re-watched videos, googled and kept on practicing over and over again. And now that I’ve been using Unity for the past six months, I am very comfortable scripting. I actually prefer to do as much as possible in C# to help keep myself learning.

Keep pushing on mate. It is an awesome feeling to come out the other side and start working on your own projects!

3 Likes

Same advice: hang in there. You’re doing all the right things, you just need to give them time to percolate and it will all start making sense.

I’m sure everyone here will be happy to answer even the most obvious sounding questions. I don’t think you ever get over hitting walls - I first started programming professionally twenty years ago, and I still rely on StackOverflow and all sorts of resources every day.

1 Like

I didn’t have as much problem with the scripting, but that may be because I had just graduated with a computer science degree and had courses which focused heavily on C-based languages. But whether it was in school or in this course, the best thing I could do was to ask questions and solicit feedback on what I was doing. Usually someone could find the tiniest little thing that was breaking my code that I had overlooked. That’s also why I’m so glad that this forum exists now in addition to Udemy, because this allows you to network and connect one-on-one in ways that Udemy didn’t.

If you want to take a step back and take a more basic C# course, that might help, especially if you’re brand new to programming. I find a lot of the courses on “Learn to program in…” usually assume you know nothing about programming, and then if you take several of them, eventually you don’t really learn anything anymore. (Speaking as someone who took a “Learn to program in C#” intending to learn the differences between other C-based languages, and everything they covered was exactly the same in C++. :stuck_out_tongue: )

1 Like

Thanks for all the replies guys! I’ve got no plans to quit on this, I’m learning this one way or the other.

I decided to just watch the video and see if at the end Ben’s solution made sense to me and I’m glad I did because some of it is not clicking with me. Hopefully someone can help me make sense of it.

Below is a test method, method name should explain the point of it pretty well.

public void T05CheckResetAtStrikeInLastFrame () {
	int[] rolls = {1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1};
	foreach (int roll in rolls) {
		actionMaster.Bowl (roll);
	}
	Assert.AreEqual (reset, actionMaster.Bowl (10));
} 

The only thing that has me a little confused above is int[] rolls but I think that might be because of my lack of understanding of the specific code below. At the end of the foreach loop above it passes (roll) back to the Bowl method but wouldn’t that be read by the Bowl method as pins? Was that simply declared as ‘roll’ for the sake of readability? Or am I just getting this all wrong?

Below is the actual code being tested to keep track of the score for the bowling game.

private int[] bowls = new int[21];
private int bowl = 1;

public Action Bowl (int pins) {
	if (pins < 0 || pins > 10) {throw new UnityException ("Invalid pins");}

     bowls [bowl - 1] = pins;

	if (bowl == 21) {
		return Action.EndGame;
	}

bowls [bowl - 1] = pins;

Is the part that is really throwing me for a loop, I watched that part of the video several times and I’m just not getting how that works. bowls was already declared above the method as an int array of 21 but then is set to what you see above in the method, what exactly did that do? Does that affect the way bowl and bowls are used later in the script?

Somethings just not clicking with me on that.

Oh my god. I feel so dumb right now haha, I figured it out. I ended up using some Debug.Log entries to track the numbers so that I could make a picture of what was happening. In the end a google search of ways to declare int arrays is what made me see just how simple this was.

If I got this right now, above the method int[] bowls was declared as an array of 21 integers all set to 0 and then in the method itself the integers in that array are set to bowl and then that bowl int is set to the pins count from whatever bowl has just taken place.

The gist of it is that I forgot arrays could be declared like that. For some reason I expected the array to equal 21 not to do what arrays do, you know, make an array of things.

2 Likes

Sometimes it’s like that. You have to actually ask the question, and then as soon as you hit “post,” that’s when you see it. Or sometimes as you’re writing the post. :wink:

1 Like

she knew this was going to happen… :slight_smile:

@Hellsrage If you’re looking for a book on C#, one that I always suggest for just starting out is Head First C# published by O’Reilly Media.

In my opinion the writing style in that book is great not only for learning the language, but also reinforces concepts in a way that makes them easy to remember. I think it is up to the 3rd edition now.

I started coding at the age of 9 , could not understand why on earth we need loops when we can just copy paste code, don’t laugh I was that stupid. But surprisingly copy pasting code and experimenting did help learn the basic of Basic then I learned DBase, clipper, C++, Assembly, Delphi , Java , C#, Python , Lisp and Pharo.

So yeah my secret weapon of learning is copy pasting other people code and changing things randomly . Lame but it works well for 28 years now.

Back when I started we would get BASICA listings in magazines and type it in… not even paste :slight_smile: Great way to learn though.

Do you remember Enter magazine? Back in the 80s, it was all about computers, and included stuff like computer programs (written in Basic), flowcharts, etc. Eventually it got absorbed back into 321 Contact Magazine, and now even 321 Contact has gone away.

1 Like

oh man, I want one of those.

1 Like

In my case it was copying from my Amstrad CPC 6128 manual locomotive Basic code of how to make a contact address book. Fun days. But frankly I prefer the Internet, back then has very hard to learn how to code.

I had exactly the same issue, only it happened earlier in the course for me. From memory I hit the wall in block breaker. Like you I looked for some c# courses and I also watched Bob Tabor’s course. Now Bob has a lot of energy, but I didn’t learn much from his course.

What I did find very helpful was the course “Programming for Complete Beginners in C#” by Eric Wise (on Udemy), the book “The Csharp players guide”, and some sites like https://dotnetcademy.net/Learn/2047/Pages/2. I also enjoyed going through http://scottlilly.com/learn-c-by-building-a-simple-rpg-index/ where you build a simple rpg just in a windows form (no graphics).

I have actually read/watched/used several other tutorials and the ones above are the cream of the crop imo for learning C#. Also you need to find ways to do lots of simple practice exercises of the concepts you learn.

The “problem” with the Unity course (for me) in terms of learning C# is that it moves quickly into the graphical side of Unity before explaining and practising some key concepts about C#. The first few projects were awesome though.

That’s pretty nifty that they have an RPG tutorial - has perfect application to what our goals are here. :smiley:

Yeah, going through the rpg tutorial I posted about above was the perfect way to coalesce knowledge of the basics of C#.

I am really looking forward to the new rpg course Ben is working on, I find the way he teaches to be the best of any video based tutorials I have watched because of how he really gets you to think and put theory into practice.

Another similar C# rpg tutorial on youtube that just focuses on code with no graphics/animations is: https://www.youtube.com/watch?v=GsxJj7X4hFw&list=PLaJIMp5C_XyH2fUg3lpYC-sYNwkkkE8rE . Unfortunately the series is incomplete and only establishes the beginnings of an rpg framework, but it helped me understand how to use several c# concepts that I had struggled with.

There have been sections where I felt overwhelmed. I suggest going over it multiple times, and if you don’t understand it, try asking a question on here about what you don’t understand too see if someone can explain it that you might understand it. I find sometimes that something will seem complicated, but someone else will explain it in simpler terms and I’ll get it right away.

When I started this course. I had no clue about C#. I’ve used Q-Basic,Turbo Pascal(yes most people won’t even know what these are cause they are so old), and GameMaker:Studio’s language. But C# was completely different then those, but I’ve go a decent handle on C# now to be able to code some basic to intermediate stuff.

Hey @Hellsrage! I too was a rank novice at programming when I started the Complete Unity Developer. I was constantly hitting walls and feeling stupid (the TDD section in particular), but I kept plugging away at it. After finishing the course I looked back retrospectively and whilst I didn’t understand it 100% I could objectively see that I was much smarter than when I went into the course.

I also recommend doing game jams. They’ll push you into space you haven’t been into and force you to improve your google skills and figuring things out on your own. Plus, they generally don’t go for too long so you don’t burn out. I’ve learnt an incredible amount from just 2 game jams.

Privacy & Terms