Search Unity

Will learning C# in XNA be the same as learning it in Unity?

Discussion in 'General Discussion' started by NickHaldon, Oct 23, 2014.

  1. NickHaldon

    NickHaldon

    Joined:
    Mar 19, 2014
    Posts:
    128
    Hello,
    As the title says, I am beginning to learn C# and I found a highly rated tutorial that uses XNA. If I learned C# in XNA would it be pretty much the same as learning it in Unity? And also what are the big differences between XNA and Unity?

    Thanks for all your help!
    NickHaldon
     
  2. calmcarrots

    calmcarrots

    Joined:
    Mar 7, 2014
    Posts:
    654
    A language is a language. You will understand how the language works and how to code.... but not in Unity. Unity uses a different API so you would have to learn how the engine works and how to program specifically for that engine. (if that makes sense). If you understand how to program, then you should have no problem learning either API.

    For example, in Unity, declaring a variable for an object:
    Code (csharp):
    1. GameObject target;
    In XNA, it might look like (im not sure exactly but you get the point):
    Code (csharp):
    1. Sprite target;

    These are really bad examples but hopefully someone with XNA experience could explain better.
     
  3. NickHaldon

    NickHaldon

    Joined:
    Mar 19, 2014
    Posts:
    128
    That makes sense. Thanks for explaining that. So basically if I learned it in XNA then switched to Unity I would have to relearn how Unity did a bunch of things.

    Thanks!
     
  4. calmcarrots

    calmcarrots

    Joined:
    Mar 7, 2014
    Posts:
    654
    Yes. Also, be sure to pick the engine that best fits your game :)
     
  5. NickHaldon

    NickHaldon

    Joined:
    Mar 19, 2014
    Posts:
    128
    What's the best engine for 3D FPS?
     
  6. calmcarrots

    calmcarrots

    Joined:
    Mar 7, 2014
    Posts:
    654
    Probably Unity, just because of the truck loads worth of scripts on the internet for a variety of things in an FPS.
     
  7. NickHaldon

    NickHaldon

    Joined:
    Mar 19, 2014
    Posts:
    128
    That's a good point.

    Thanks for your help!
     
  8. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    xna has been abandoned by Microsoft so don't bother. I'm a former xna developer :). C# is C# so what you learn will translate but the language is easy. The biggest hurdle is learning the framework. There are two components at work here. One is learning the .net framework, and the other is learning the API. What you learn of the .net framework will directly translate between xna and unity but as the API bits are different you'd be just as well off using a general c# book and learning by writing console apps.

    it is also very hard to compare unity and xna. Xna is not an engine. It is strictly a framework that provides an abstraction on top of DirectX. Aside from the game loop, you are responsible for building the engine. Unity provides both an engine and an API and does a lot of the boring low level work for you. There is a catch however. Unity uses a mono version roughly equivalent to .net 3.5 whereas xna was 4.0 so it doesn't all directly translate.
     
    Ryiah, Deleted User and calmcarrots like this.
  9. NickHaldon

    NickHaldon

    Joined:
    Mar 19, 2014
    Posts:
    128
    I was planning on only using XNA to learn how to code in C#. I just thought afterwards that I should ask what's the difference between it and Unity. I found a tutorial that had a bunch of really good reviews. That's pretty much the only reason I am using it.

    It sounds like Unity is much better overall then XNA. Thanks for both of your guys help. I appreciate it a bunch!
     
  10. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    if you want to see xna in action, look at my blog (link in signature) and look at my xna terrain tutorial. 7 pages of tutorial with loads of code just to render a single texture terrain with LOD and culling. Then you'll change your mind about wanting to check out xna :). And please excuse any typos... Writing these replies on my phone while I wait for a car tire repair.
     
    zDemonhunter99 likes this.
  11. tango209

    tango209

    Joined:
    Feb 23, 2011
    Posts:
    379
    As Dustin mentioned, XNA is dead and he also covered the differences between it and Unity quite well. The only thing I would add is give the Unity Tutorials a go as they are nice quick intros to the different topics as they pertain to Unity. There are a lot of resources on the web if you need clarification or want to delve into more depth on a topic.

    Also, people are very friendly and helpful on this forum if you take the time to at least do a quick google before hand and demonstrate that you've put a little effort in before asking for help.

    http://unity3d.com/learn/tutorials/modules
     
  12. calmcarrots

    calmcarrots

    Joined:
    Mar 7, 2014
    Posts:
    654
    I think we are done with this thread.
     
  13. Tanel

    Tanel

    Joined:
    Aug 31, 2011
    Posts:
    508
    I'd just second getting a C# book and doing some simple console stuff first. I gather you haven't done anything in C# before, so going straight to Unity might be overwhelming.
     
  14. smd863

    smd863

    Joined:
    Jan 26, 2014
    Posts:
    292
    XNA is dead, but it really wouldn't hurt to go through some really good tutorials and use some of the lower level graphics APIs. Set up some vertex buffers, textures, shaders, etc. manually. You will have a better understanding of how things work under the hood and more appreciation for everything Unity is doing for you (on multiple platforms).
     
  15. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    This is my road map for learning C# and C# with unity:
    First start with http://unity3d.com/learn/tutorials/modules/intermediate/scripting/properties *go through the list on the right.
    Second: pick up a book on C# with preferably visual studio as the IDE. I got "MS Microsoft Visual Csharp 2013 Step by Step".
    Third: go back and go through http://unity3d.com/learn/tutorials/modules/beginner/scripting/scripts-as-behaviour-components *the list on the right again

    And lastly go ahead and get some asset store MINI games. RIP THEM APART until you understand it.

    Then start recreating some SIMPLE games that are popular and put some of your own touch on them as a learning experience.

    Hope this helps!!

    PS. Don't get ahead of yourself this is not a one day or a week thing, take your time! Might take a month or two, but with patience in mind you will come out of it with a better understanding!
     
    Last edited: Oct 24, 2014
  16. NickHaldon

    NickHaldon

    Joined:
    Mar 19, 2014
    Posts:
    128
    Thank you all for your answers!

    @tango209 I probably should have looked into the Learn section more. That's my bad. I'll also work harder on looking stuff up before I ask. I just find it some much easier to talk to real people. Oh well.

    @Tanel I plan on getting a C# book but for now I have a written tutorial online. Its worked really well for me so far. I've done more in it then in the other video tutorials I watched.

    @CaptainScience That's a good idea. I was just going to learn C# and then switch back into Unity right afterwards. Its probably a good idea to understand what the engine does for you so you really appreciate it. Thanks!

    @Darkoo Thanks for the road map! I've done some brief skimming inside the Learn section. It looks really good. Its hard to not get excited and try to delve right in and work on a fully fledged game. I'm trying as hard as I can to hold myself back! :)

    Thanks again all!
     
  17. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I think he was referring to technical questions in the future and not directing it at your original question. Your original question really wasn't something easy to determine with a simple Google search and required feedback from folks who have experience with Unity and those who had experience with XNA. It was a perfectly appropriate question for the forums so no worries. :)

    On the other hand, if you ask a question like: "How do I instantiate a new game object?"... well those types of questions are easily answered just by reading the documentation or a quick Google / Bing / Engine of Choice search, so those are what were being referred to... it was more of a head's up. Also, avoid general questions like "How do I make an MMORPG?" or "How do I make a GTA size map?". But based on your conversation participation so far I don't foresee that happening.

    Happy learning!

    ~Dustin
     
    NickHaldon likes this.
  18. tango209

    tango209

    Joined:
    Feb 23, 2011
    Posts:
    379
    I tend to be a little to terse and should have been clearer. It wasn't a dig at you, just a tip for you and any others new to the forums who might read this thread.
     
    NickHaldon likes this.
  19. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    The language itself will be the same. The biggest differences will be in the Unity API (and the XNA one). For example, a lot of my code consists of things like:
    • Serialization-dependent objects
    • Classes like Transform, Vector3, Quaternion, Texture
    • Coroutines
    I haven't used XNA, but I'm assuming that, if these things exist at all, their syntax and implementation would be very different.
     
    NickHaldon likes this.
  20. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    It's largely the same at that level. Vector2, Vector3, Matrix4x4, etc. The big difference really is API. You're not simply adding gameObjects... you're writing the Update, Render, LateUpdate code into your game objects and managing them yourself. This includes manually managing vertex and index buffers for some things (models are handled for you) and managing material passes yourself. Although it was pretty handy to be able to enumerate material passes and change object properties between passes. Having 32-bit index and vertex buffers was also nice.
     
    NickHaldon and Deleted User like this.
  21. NickHaldon

    NickHaldon

    Joined:
    Mar 19, 2014
    Posts:
    128
    @Dustin Horne I realize that now. :/ I'm still new to forums and am having trouble with the stuff that people don't really say but mean. I'm happy that my conversation participation makes you feel that way. :)
    Thanks!

    @tango209 Its fine. I'm often probably more terse then you :D.

    @StarManta Thanks for adding to the conversation! I'll look into more of what you said later on. I don't have enough knowledge to check it know. :)