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?
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:
GameObject target;
In XNA, it might look like (im not sure exactly but you get the point):
Sprite target;
These are really bad examples but hopefully someone with XNA experience could explain better.
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.
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.
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!
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.
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.
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.
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).
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!
@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_1 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!
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.
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.
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.
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.