• Advertisement
Sign in to follow this  

Unity Using .NET framework in games?

This topic is 3226 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heya all. Im Quil and I want to be a Game coder. Im currently learning C++, started from the basic, and I know pretty much (I think :P) now. I know Pointers, References, OOP, and ofcourse all basic things. My dream Goal is to make a MMORPG. I know its still a long way to get there, so I joined this community for some help. At school im doing the "HAVO/VWO" but im going for "VWO" (my marks are mainly 9s and 10s. 10's for math and English). It is the highest level of school we have here in Holland. (High school, as im 13). I have MUCH time to learn (10-14 hours a day) because im in the hospital for Leukemia. With all those extra Medicin's today feeling bad is not happening anymore.. So its alot of computering! =D Anyway, last night I was wondering. Is it wise to use the .NET framework (I already did C# and Visual Basic and PHP before I started learning C++) in the client or server? It has really nice functions, and they are all pretty easy to access. It is just Random rand = new random; (in C#) and then you have access to all random functions. Im learning from a Win32 command-line with the Visual C++ Compiler. That means there are no .NET features in. I want to use the same software the proffesionals do, as I have a photograpic memory (if its bad english: I can remember every detail without problems, I pwn the game Memory). So, what do you think? Is using the .NET framework in a server/client for a game nice?

Share this post


Link to post
Share on other sites
Advertisement
I already did. It was around the time I used to program in C#. Was pretty newb back then. Wanted to make MMORPG without even knowing anything about XNA. Thats bad. I know better now. xD

Nah, I prefer DirectX more. Because it is more proffesionel, and I want to do real coding. I want a job in the Game Coding later. So im already learning today. ^^
Anyone has an other answer..?

[Edited by - Quil on April 19, 2009 2:44:58 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Quil
I already did. It was around the time I used to program in C#. Was pretty newb back then. Wanted to make MMORPG without even knowing anything about XNA. Thats bad. I know better now. xD

Nah, I prefer DirectX more. Because it is more proffesionel, and I want to do real coding. I want a job in the Game Coding later. So im already learning today. ^^
Anyone has an other answer..?

First of all, when you're a beginner, you should use beginner tools, so that you learn the basics and proper techniques. DirectX isn't better than XNA on your level - with XNA you can focus on making a game and having fun, while with DirectX you will most likely be working on a low-level code, barely touching the game at all.

Also - even a MMORPG is doable on XNA, proof here

Share this post


Link to post
Share on other sites
Quote:
Original post by i_luv_cplusplus
First of all, when you're a beginner, you should use beginner tools, so that you learn the basics and proper techniques. DirectX isn't better than XNA on your level - with XNA you can focus on making a game and having fun, while with DirectX you will most likely be working on a low-level code, barely touching the game at all.

Also - even a MMORPG is doable on XNA, proof here


I would say.. Everyone here started out with low-level codes. I want to learn C++, not C#. I already know C#. And I want to learn DirectX. Not XNA. I already read some tutorials about DirectX, spitted though the code, trying to understand. I know you cant do DirectX well without knowing C++ well. But I have no idea what to know in C++ before I can do DirectX. Im not looking at XNA.

Maybe you can tell me some C++ points where I need to have knowledge about to be "ready for directx" in your eyes? (or someone else..?)
Add: I didnt say XNA could make a MMORPG. I said that when I tryed to, it was like install XNA and think you can make the MMORPG with your basic C# knowledge.

[Edited by - Quil on April 19, 2009 2:37:02 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Quil
I already did. It was around the time I used to program in C#. Was pretty newb back then. Wanted to make MMORPG without even knowing anything about XNA. Thats bad. I know better now. xD

Nah, I prefer DirectX more. Because it is more proffesionel, and I want to do real coding. I want a job in the Game Coding later. So im already learning today. ^^
Anyone has an other answer..?


The basics of game programming are the same, whether you're using XNA, or DirectX, or OpenGL. The APIs may be slightly different, but the actual work that has to be done is the same - it's a function of the math needed to do the transforms, etc. It's like reading a file. The API may change in different languages, and you may have to do some low level stuff in some languages that others take care of for you, but the main tasks that you do are the same in any language.

If you really want to program in DirectX, use C++. If you want to use C#, use XNA.

If you're a beginner (and I don't mean that in an offensive way at all), I'd recommend C#/XNA, as it'll remove a ton of problems that you'd have to deal with in C++/DirectX.

Once you've got some basic stuff in C#, you can make a decision if you want to move to C++ or not. The knowledge you've gained will carry over, even if you have to relearn some specifics.

Share this post


Link to post
Share on other sites
DirectX more professional? XNA is a .NET wrapper for Direct3D 9.0, plus its optional content pipeline some helper classes that make it easier for beginners to get something on the screen. Whether you use those helper classes is up to you.

The first thing you should do if you want to be professional is to not disregard technologies because of some gut feeling or because they're marketed as being "easy" - but to make an informed decision after knowing the facts.

If you want DirectX 10 and 64 bit, there's also SlimDX, a .NET wrapper for Direct3D that supports DirectX 10. Or Tao.OpenGL if you want to use OpenGL - as an added bonus, the Tao libraries work on linux as well.

.NET is a valid choice for an MMORPG, it has very good networking support, database integration, linux portability and its memory management will automatically prevent memory fragmentation and other issues you'll have to solve by hand in C++. The simple decompilation of .NET code might allow even novice programmers to attempt cheating <insert usual notice by random gamedev.net member that obscurity isn't security, that seasoned programmers can read assembly just as well>

C++ on the other side gives you more control over your memory management, eg. object pooling or memory mapping of files, which - in the hands of someone with several years of programming experience - can be effective getting certain demanding algorithms into the real-time range. But this is mainly a concern in cutting-edge graphics or AI.

Share this post


Link to post
Share on other sites
Quote:
Original post by kyoryu
Quote:
Original post by Quil
I already did. It was around the time I used to program in C#. Was pretty newb back then. Wanted to make MMORPG without even knowing anything about XNA. Thats bad. I know better now. xD

Nah, I prefer DirectX more. Because it is more proffesionel, and I want to do real coding. I want a job in the Game Coding later. So im already learning today. ^^
Anyone has an other answer..?


The basics of game programming are the same, whether you're using XNA, or DirectX, or OpenGL. The APIs may be slightly different, but the actual work that has to be done is the same - it's a function of the math needed to do the transforms, etc. It's like reading a file. The API may change in different languages, and you may have to do some low level stuff in some languages that others take care of for you, but the main tasks that you do are the same in any language.

If you really want to program in DirectX, use C++. If you want to use C#, use XNA.

If you're a beginner (and I don't mean that in an offensive way at all), I'd recommend C#/XNA, as it'll remove a ton of problems that you'd have to deal with in C++/DirectX.

Once you've got some basic stuff in C#, you can make a decision if you want to move to C++ or not. The knowledge you've gained will carry over, even if you have to relearn some specifics.


Yes. I really want to program in DirectX. I think it is an challenge to do something more hard, and that will keep me satisfied. And, when I do C#/XNA, I wont be learning anything about some subjects that only are in C++, like pointers. (Yes I already know them, but the best is to also put them in practice right? Not only in a learning program..)

Quote:
Orginal post by Cygon
DirectX more professional? XNA is a .NET wrapper for Direct3D 9.0, plus its optional content pipeline some helper classes that make it easier for beginners to get something on the screen. Whether you use those helper classes is up to you.

The first thing you should do if you want to be professional is to not disregard technologies because of some gut feeling or because they're marketed as being "easy" - but to make an informed decision after knowing the facts.

If you want DirectX 10 and 64 bit, there's also SlimDX, a .NET wrapper for Direct3D that supports DirectX 10. Or Tao.OpenGL if you want to use OpenGL - as an added bonus, the Tao libraries work on linux as well.

.NET is a valid choice for an MMORPG, it has very good networking support, database integration, linux portability and its memory management will automatically prevent memory fragmentation and other issues you'll have to solve by hand in C++. The simple decompilation of .NET code might allow even novice programmers to attempt cheating <insert usual notice by random gamedev.net member that obscurity isn't security, that seasoned programmers can read assembly just as well>

C++ on the other side gives you more control over your memory management, eg. object pooling or memory mapping of files, which - in the hands of someone with several years of programming experience - can be effective getting certain demanding algorithms into the real-time range. But this is mainly a concern in cutting-edge graphics or AI.


Yes, I think DirectX is more proffesional. Firstly because you use DirectX with C++, and C++ is, as you said, a more advanced language as C#. Secondly, because it is more harder to do. Like initializing the whole thing. XNA doesnt have to do that, I know.

But okay, I promise I dont disregard anything anymore because it is 'easy' or 'the proffesionals dont use it'. Im here to learn after all, right? Well learning shouldnt be a problem. :P

As I said before in this post, I rather do C++ with DirectX. And besides 'the proffesionals do it' I will tell you why.

Firstly, because I want to do something that is harder. It will get myself the feeling its a challenge, which will get me satisfied, which will make me learn faster. If I can learn faster as im doing already. If im doing C# and XNA, I probaly (Altough it isnt true, but I have autism, and a feeling can mean alot to me..) get the feeling im wasting time because it isnt that hard. (I said it will be pretty false! xD).
So: I will get a feeling im wasting time because it isnt hard. Feeling means alot for me, so I get bored quickly. But I know it isnt true. But im still bored. I know it sounds really strange, but Autism ís really strange.

Secondly, because I know it is more rewarding on Longtime. As you said a programmer with a few years of experience can do alot more with C++ and directX then with C# and XNA. So if I learn C++ and DirectX, and I wont quit it, it will give me an advance in a few years. When those Cutting-edge graphics and very advanced AI come in :P

Share this post


Link to post
Share on other sites
I think it's best to work with the same language for both the client and server. You can share types and structures and some code, and it's easier to maintain.

You can certainly write in C#. You'll likely be more productive, and learn a lot--the core concepts (of eg a 3d renderer, or network synchronization) are the same. When you get down to it, APIs like D3D or Sockets aren't that much "higher level" in C#. Just safer and easier to manage.

But like you said, if you're trying to learn C++, learn C++. The Direct3D API is good. There'll be a lot of win32 cruft to work through, and you'll have at least 1 segfault that you can't track down, but it'll be fun. Read this http://www.parashift.com/c++-faq-lite/. Once a week.

Share this post


Link to post
Share on other sites
if you don't mind being limited to the windows/xbox platform then go with c#/net.
for hobbyists and fast prototyping c#/net is really awesome.

if you're more serious about gamedev (and maybe want to port your games to other platforms) you should learn c++ :(

Share this post


Link to post
Share on other sites
Quote:
Original post by jrk
if you don't mind being limited to the windows/xbox platform then go with c#/net.
for hobbyists and fast prototyping c#/net is really awesome.

if you're more serious about gamedev (and maybe want to port your games to other platforms) you should learn c++ :(


Yea, I am really serious about gamedev :P I want a job in the game industry later, want to make games, thats just my true dream! And im not giving it up anywhere, next 40 years! Maybe I'll pwn asses (40 year experience, lol) then, but not now. I know im still a beginner. But everyone was once a beginner. And they learned it too. =)

Share this post


Link to post
Share on other sites
Quote:
Original post by jrk
if you don't mind being limited to the windows/xbox platform then go with c#/net.
for hobbyists and fast prototyping c#/net is really awesome.

if you're more serious about gamedev (and maybe want to port your games to other platforms) you should learn c++ :(

Well, I used to use C++ and DirectX but switched to OpenGL some years ago, mainly for Linux compatibility reasons. Besides the syntax the algorithms are mostly the same.

Recently I started to port my engine from C++ to C# for productivity reasons. C# allows me to quickly write code that runs on windows and linux as well. And some of C#'s features help productivity a lot if used correctly, like automatic memory management along with GC, delegates and events, etc.

Share this post


Link to post
Share on other sites
Quote:
Original post by jrk
if you don't mind being limited to the windows/xbox platform then go with c#/net.
for hobbyists and fast prototyping c#/net is really awesome.


...add Linux, Windows Mobile based PDAs, iPhone, MacOS and Zune to that list.

Of course, .NET will probably never see the light of day on the PS3, which is a complete show-stopper for usage of .NET in AAA titles.

@Quil:
All valid reasons!

Just for the books: XNA is at it's core really just a wrapper around DirectX. Initializing the whole thing can be done automatically if you use Microsoft's "Game" class, but also manually by creating the GraphicsAdapter yourself, which includes all the gory details involved in normal DirectX initialization.

Maybe I have lost some perspective over the years -- for me wrestling with an API has become menial work and if something lets me avoid it without breaking any of my requirements, I'm happy to comply. I do remember the time when I was excited over creating the most OS-conformant and efficient rendering window, main loop or Direct3D setup, but over time, that became less and less interesting =)

You can certainly learn a lot about reference counting, resource management and meticulous attention to correct API usage with Direct3D. Good luck on your way!

Share this post


Link to post
Share on other sites
In my professional career, I have never used DirectX or OpenGL directly. Like Cygon, I avoid having to get close to the graphics API because it doesn't interest me.

If you intend to use the .NET frame with C++, you have to use Managed C++ at which point you may as well use C#.

Where is your focus on the MMORPG? Is it the networking? Rendering? Gameplay? Personally, I would focus on one area and take as many shortcuts as possible with other areas to minimise the amount of time to spend on it.

Share this post


Link to post
Share on other sites
Im new at gamedeveloping too and im in the same situation. Which language to pick. I think i have been convinced to go with the C#/XNA, but there is only one problem. Where is the books!?!

Which C#/XNA books would you guys recommed for a newbie game programmer like me? There have to been something about how to implement 3D models made in for example 3D Max.

Share this post


Link to post
Share on other sites
Poku,

books have always been a bad way to learn about gamedev. The XNA tutorials are amazing. I'm actually porting my C++/DirectX game over to C#/XNA because of the lack of documentation for XAudio2 (the replacement for DirectSound).

Quil,

When I was a hobbyist I programmed in C++ because I loved it. Then I became a professional programmer (not gamedev though) and now I program my games in C#. Why? Because professionals aren't concerned with showing off talent. We'd rather do things the easy way, enjoy the fruits of our labors, and move on.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By Manuel Berger
      Hello fellow devs!
      Once again I started working on an 2D adventure game and right now I'm doing the character-movement/animation. I'm not a big math guy and I was happy about my solution, but soon I realized that it's flawed.
      My player has 5 walking-animations, mirrored for the left side: up, upright, right, downright, down. With the atan2 function I get the angle between player and destination. To get an index from 0 to 4, I divide PI by 5 and see how many times it goes into the player-destination angle.

      In Pseudo-Code:
      angle = atan2(destination.x - player.x, destination.y - player.y) //swapped y and x to get mirrored angle around the y axis
      index = (int) (angle / (PI / 5));
      PlayAnimation(index); //0 = up, 1 = up_right, 2 = right, 3 = down_right, 4 = down

      Besides the fact that when angle is equal to PI it produces an index of 5, this works like a charm. Or at least I thought so at first. When I tested it, I realized that the up and down animation is playing more often than the others, which is pretty logical, since they have double the angle.

      What I'm trying to achieve is something like this, but with equal angles, so that up and down has the same range as all other directions.

      I can't get my head around it. Any suggestions? Is the whole approach doomed?

      Thank you in advance for any input!
       
    • By khawk
      Watch the latest from Unity.
       
    • By GytisDev
      Hello,
      without going into any details I am looking for any articles or blogs or advice about city building and RTS games in general. I tried to search for these on my own, but would like to see your input also. I want to make a very simple version of a game like Banished or Kingdoms and Castles,  where I would be able to place like two types of buildings, make farms and cut trees for resources while controlling a single worker. I have some problem understanding how these games works in the back-end: how various data can be stored about the map and objects, how grids works, implementing work system (like a little cube (human) walks to a tree and cuts it) and so on. I am also pretty confident in my programming capabilities for such a game. Sorry if I make any mistakes, English is not my native language.
      Thank you in advance.
    • By Ovicior
      Hey,
      So I'm currently working on a rogue-like top-down game that features melee combat. Getting basic weapon stats like power, weight, and range is not a problem. I am, however, having a problem with coming up with a flexible and dynamic system to allow me to quickly create unique effects for the weapons. I want to essentially create a sort of API that is called when appropriate and gives whatever information is necessary (For example, I could opt to use methods called OnPlayerHit() or IfPlayerBleeding() to implement behavior for each weapon). The issue is, I've never actually made a system as flexible as this.
      My current idea is to make a base abstract weapon class, and then have calls to all the methods when appropriate in there (OnPlayerHit() would be called whenever the player's health is subtracted from, for example). This would involve creating a sub-class for every weapon type and overriding each method to make sure the behavior works appropriately. This does not feel very efficient or clean at all. I was thinking of using interfaces to allow for the implementation of whatever "event" is needed (such as having an interface for OnPlayerAttack(), which would force the creation of a method that is called whenever the player attacks something).
       
      Here's a couple unique weapon ideas I have:
      Explosion sword: Create explosion in attack direction.
      Cold sword: Chance to freeze enemies when they are hit.
      Electric sword: On attack, electricity chains damage to nearby enemies.
       
      I'm basically trying to create a sort of API that'll allow me to easily inherit from a base weapon class and add additional behaviors somehow. One thing to know is that I'm on Unity, and swapping the weapon object's weapon component whenever the weapon changes is not at all a good idea. I need some way to contain all this varying data in one Unity component that can contain a Weapon field to hold all this data. Any ideas?
       
      I'm currently considering having a WeaponController class that can contain a Weapon class, which calls all the methods I use to create unique effects in the weapon (Such as OnPlayerAttack()) when appropriate.
  • Advertisement