Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Is Unity a good fit for my project?

Discussion in 'General Discussion' started by Evolubobs, Feb 27, 2015.

  1. Evolubobs

    Evolubobs

    Joined:
    Feb 27, 2015
    Posts:
    2
    Hi, I am currently working on a project using XNA and Farseer Physics (C#), and I'm wondering if the Unity framework would be a good fit. I want to make the switch because it seems very well supported and active, and XNA / Monogame looks like it's dying :(

    My project is not a game. I am evolving virtual creatures in a petridish (neural networks / genetic algorithms), and I am using the XNA framework for visualization. Here is an example of what I am using XNA for

    Because my project is not a game, I have unusual requirements, and I'm not sure Unity is a good fit.

    Running the game in "job" mode :
    I need to be able to run the game completely without graphics, much faster than a normal game loop. For example, if the normal game loop execute 60 updates per second, I need for be able to run the game, without any graphics, as fast as the cpu will let me.

    Currently I am using winforms to set some parameters, and then launch serveral instances of my "game". (My game is a genetic algorithm that learns over time, so when I am not visualizing the results, I need the game to go as fast as possible). Here is an example of what my winforms console looks like

    Language
    My entire code based is in C#, and I am using Visual Studio as an IDE. I am using winforms to launch my XNA game, is the same thing possible in Unity?

    Thank you for your answers!
     
  2. lorenalexm

    lorenalexm

    Joined:
    Dec 14, 2012
    Posts:
    307
    From what I understand MonoGame has been more active of recent then in the past, with support for the PS4 having been announced a year ago, though XNA surely has seen the light at the end of the tunnel.

    I do not know about WinForms integration with Unity, but without a doubt you would be able to make something work to function as you'd like. My bigger question though is, why would you? Not that I am against Unity in any way, but from the sounds of it you are a fair way into your project now, to the point where you have it functioning even.

    I am just struggling to see the sense in switching, even if you are using a debatably decrepit, does your project really need the more up to date graphics processing when - as you've stated - you're project will be running headless aside from configuration? I feel as though you may get more mileage by using pure C# and making usage of the threading and drawing libraries provided.
     
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Unity could work out for your visualisation steps.

    For your job steps you are better off running outside of Unity. Unity doesn't have a headless mode, and will waste a lot of cycles on rendering and the various other overheads. Even if you run your entire simulation in one frame Unity will still take its cut of resources. Far better running on a machine that has nothing else to do.

    Is there a reason you need the simulation to run inside an engine, rather then just on its own straight out of a console app?
     
  4. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    352
    This look very interesting.

    If you are concerned about speed, well Unity`s engine runs on C++ but you script in C# so that may slow things down a bit.

    Normal game loop, without any stuff in C++, my cpu can run it maybe 5000+ times per second(Not Unity). Add multithreading and you have a nice path to squeezing everything out of your CPU.
    But Unity`s API is not thread safe, so you cannot use multithreading sadly. Only if you don`y use Unity`s API, then it is possible. (Nothing from MonoBehaviour, which is almost impossible to make a game without, in Unity)

    If you do not care about graphics, just about speed, and you know C++, go with C++ and openGL/SFML for 2d graphics.
    That way you can get the best speed out of fast pre-compiled language, can run multiple threads on your CPU cores and have simple graphics representing state of your game.

    But if you think Unity will be enough, it is one of the best engines out there, it doesn`t support multithreading, but you can do things really fast, and it is reliable with lot of Support on forums and activity, as you said yourself.
     
  5. Evolubobs

    Evolubobs

    Joined:
    Feb 27, 2015
    Posts:
    2
    Thank you for all the replies! The specific reason I am looking to switch is because I am starting a blog about this project, and, for now, I am uploading gfycats to demonstrate specific behaviors of my creatures (http://evolubobs.com/).
    I wanted to put a web version of my visualizer on my site, and unity web player looks like it is well on it's way, whereas the options for doing the same in XNA (JSIL) are not mature enough yet.

    Multi threading is definitely required, most of the time I run 8 different simulations and I let them run at night to get "intelligent" creatures in the morning.

    The physics engine is the same for the visualization and the generation step, and I am able to do this with XNA (by using only the framework, not the graphics).

    Again, thanks for your answers.

    Edit: I think I will end up coding a web visualizer on it's own, I had hoped to keep the code bases in one place, and use an automated process to make the switch to html 5, but it looks like I won't be able to do that.
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    Yes, it does.

    http://docs.unity3d.com/Manual/CommandLineArguments.html

     
    Ryiah, Kiwasi and shkar-noori like this.
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Huh. That's awesome. In which case its entirely plausible to run the job mode inside of Unity. You can pretend Update is running at your simulation timestep and thus run the game as fast as possible.
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Also, multithreading is very possible. Anything that CPU-intensive is just going to be "plain math stuff" which doesn't use MonoBehaviour anyway.

    --Eric
     
    Ryiah and Kiwasi like this.