Search Unity

Do I know enough c# to make good use of the unity engine?

Discussion in 'Scripting' started by FarzanZand, Jul 29, 2013.

  1. FarzanZand

    FarzanZand

    Joined:
    Jul 29, 2013
    Posts:
    14
    Hi there people!
    I want to start using unity and increase my talents to become commercially viable. I want to know how much c# I should know before I focus on tutorials for the unity engine and then learn more c# scripting through unity.

    I do know the basics of c# and its syntax. Classes, constructors, namespaces, methods. Can I make good use of the unity engine and its tutorials with my current knowledge or should I spend more time on purely learning c# outside of the engine? at the moment, I am half way through the c# head first book.

    By the way, how are the tutorials on the unity website? Are they good? They seem good at first glance.

    Thanks in advance and I appreciate any assistance I can get!
     
  2. AlteredReality

    AlteredReality

    Joined:
    Aug 15, 2011
    Posts:
    397
    If you understand the basics of C#, I'd think you would be just fine using it in Unity. They do a very good job of using C# with their engine. As for the tutorials, I'm not sure to be honest, as I've not really used any. I'm a programmer, so I normally reference code directly if I need to figure out how to do something.
     
  3. Mister-E2

    Mister-E2

    Joined:
    Jun 6, 2013
    Posts:
    179
    Before you get into using C# with unity, I suggest you go over the following subjects:

    events
    delegates
    Inheritance
    Interfaces
    Decouple as much as possible

    All of these are solid things to learn and are useful for most other languages aswell as C#. But I am suggesting to learn all these specifically because I made my first game in Unity with C# "basic" knowledge. It was dreadful, I had references going every direction, scripts relying on other scripts to accomplish things etc.

    Good luck
     
  4. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    The stealth tutorial is very good, but still unfinished, I think. What's there will teach you useful things.
     
  5. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,878
    I started with zero knowledge of c# but i learnt on my way so easily. I knew c++ though so it helped.
     
  6. cjow

    cjow

    Joined:
    Feb 29, 2012
    Posts:
    132
    Stealth tutorial is finished now.

    You don't need to know very much to build a small game in Unity. Just an idea and some determination. My advice is just dive in and learn by doing. If you encounter something you don't understand in a tutorial just consult the scripting reference or ask around on the forums. Most people are quite happy to help if they can.
     
    Last edited: Jul 30, 2013
  7. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    Oh, awesome!

    The original poster has mastered the art of making a good subject for the thread, so getting help should be easy :)

    The stealth tutorial by Unity Tech. is a great complete project, and BurgZerg Arcade's long series of tutorials cover a lot more in smaller chunks. There are other tutorials which you'll probably see suggested if you view the latter on YouTube, and quality varies. But generally any tutorial maker who has more than one video can be worth checking out.

    I suggest just hopping around between tutorials relating to what you need to do once you know how to get started. Mister-E2's list above can be considered essential C#. The first few scripts are likely to see some rewrites until you get the hang of the style anyway. Just remember that Unity is a component-focused engine; give each object exactly the functionality it needs. Write scripts as self-sufficient as you can, but consider a main "game controller" script if it makes sense. You typically have either a player character controller, or a more generic game controller attached to the camera if there is no player representation in the game (like an RTS).

    A short piece on this model: http://www.gamasutra.com/blogs/Mega...ame_Engines_101_The_EntityComponent_Model.php
     
  8. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    Just my two cents here...

    Your c# is probably more than enough to make a game. The real issue is some boring knowledge that all of us programmers once hated like good programming practices, code readability, flexibility and a good grasp of design patterns. Ah, and optimization... how many hours didn't I spend optimizing code that even not optimized would never affect the game frame rate...

    My hint is, if your project gonna scale (more than 10k lines of code), be sure to know a lot about object orientation techniques, a good feeling for software engineering (you want to use most of your time on new features, instead of refactoring code) and be able to decide what data structures you will use before you start actually coding anything.

    One thing, real time software (as games) are different from others software in its own way. Take unity and develop. Practical experience together with learning from mistakes and problems is worth more than a dozen of books.
     
  9. pailhead

    pailhead

    Joined:
    Oct 8, 2012
    Posts:
    68
    is it harmful, how much if it is it, to just start experimenting with code?

    I knew absolutely nothing two months ago, but looking at examples, and watching an as3 coder work with away3d, helped me understand some things. I look at vectors, imagine that stuff in space and I know what's needed to get an angle, a distance, and how to get it. Shaders make perfect sense since they are more or less straightforward, i see it as lines and lines of equations. I looked at some AGAL examples and saw how they shift variables from one register to another depending on the size and I think that I'm getting a good idea of what is happening under the hood. What I want to say is, shaders seem confined, the rendering happens after the entire game logic did, and it seems like a pretty straight forward process from there on.

    I still get very confused with calling other scripts, types, etc. and I understand that it's the basics of CS that I lack. But when I started reading a book on Java, the author jumps into calling classes and extending classes with pretty abstract examples, and I can't make heads or tails from it. Working in 3d however helps me explain exactly what is going on, and makes way more sense of code. I was wondering if i'll have to undo some damage by doing things the way I am now?

    Here is what I was able to muster in a couple of days after a bit of experimentation. I was able to organize arrays so to split these sub meshes within a mesh. The new ngons that get generated are being generated within the same mesh, the coordinates are pretty abstract, i just increment x,y,z in a certain way, and do no math on the cpu. Once sent to the vertex shader, it constructs the pattern, and deforms it.

    Procedurally generated mesh

    This worked, but I struggled for another three days to assemble the GUI and wire it to the other stuff, which ended up being a few lines of code and I'm still not quite sure what i've done to fix the meshes from leaking into the scene which was causing a crash. The counters i'm using to loop through the arrays are probably a huge mess.

    I bought "c# 5.0 in a nutshell" and "Mathematics - for 3d game programming...". I guess the bottom line question would be, should I stop playing so much in unity and specific problems, before I go through an entire c# book?
     
    Last edited: Jul 30, 2013
  10. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    There is no better way to learn then just diving into something real. Your learning will be greatly accelerated by working on a real project. Solving specific problems on the way to a real goal tends to focus you much more, in addition to just being more fun and interesting.

    If there was any one thing I would tell a new developer, it is to always look to see if the problem you are solving has already been solved. You will learn the language syntax and idioms fast enough, you don't need to reinvent the wheel as a learning exercise. There will be plenty of code to write in between the third party libraries you use.
     
  11. FarzanZand

    FarzanZand

    Joined:
    Jul 29, 2013
    Posts:
    14
    Thank you very much everyone! This is a lot more help than I expected and it really made me happy. You all answered my questions perfectly and I truly appreciate it.

    I will make sure to put your advice to great use!