Search Unity

Unity able to manage full-scale stellar systems ?

Discussion in 'Editor & General Support' started by Mutos, Jan 12, 2010.

  1. Mutos

    Mutos

    Joined:
    Jan 12, 2010
    Posts:
    9
    Hi all,


    I've just discovered Unity and would like to use it in my "Stars of Call" project, which involves full-scale stellar systems as it is an Elite-like game.

    My question is just : Is Unity able to manage the full-scale stellar systems I need, with orbiting planets and moons and starship movements ?

    Below is a copy of an early Stellar Systems Editor I made years ago. It shows the kind of look I want to achieve for the tactical system map.

    Thanks in advance for any hint !
     

    Attached Files:

  2. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    It can, but you'll need to think about the scale of numbers to be used. For example, it's likely a bad idea to use meters as your base unit as then the distance values involved, and/or gravitational forces calculated, will be at "extreme" values and can thus induce rounding errors, data precision errors, etc. For example, I knocked out this little demo:

    OrbitSim

    It's a scale simulation of our inner solar system and it's all moving based on mutual gravitation (I position the bodies, give them each an initial velocity and then let the gravity sim run). The only thing not to scale is the physical size of each body, those are greatly magnified for the sake of better display (at actual size most would be sub-pixel in size :) ). But in order to do this I had to "tinker" with my choice of units quite a bit:

    Distance: instead of assuming that each distance unit in Unity is 1m, I assume that each unit in Unity is 1 AU (AU = average distance of Earth from the Sun, or 1 AU = 1.49599 x 10^11 meters).

    Mass: instead of assuming that each mass unit in Unity is 1 kg, I assume that each unit in Unity is 1 Earth mass, (1 E = 5.9742 × 10^24 kg).

    Time: instead of assuming that each time unit in Unity is 1 second, I assume that each unit in Unity is 1 day (1 D = 8.64 x 10^4 seconds).

    I had to do those to make the math workable, and other values may yet be necessary if I wanted to try and model the entire solar system. So it's doable, but with some tinkerin'! :)
     
  3. dpentecost

    dpentecost

    Joined:
    Apr 3, 2009
    Posts:
    136
    Ah, you folks who can "knock out a demo" like that!

    Higgy, could possibly upload the project for the demo? I am working on various Unity demos for fulldome theater (planetarium) projection - using Bourke's fisheye lens in-game camera - and I would love to study it.

    Thanks!
     
  4. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    Well, I was a Physics major in college and my senior project was to write an orbital motion simulator* so I've done this before. :)

    *To replicate the motion of what were then newly found extra-solar systems of planets around stars. I tried to back up a PhD thesis of someone else that was asserting that the highly elliptical planetary orbits being found were due to the stars being in binary systems (and the secondary star "pulls" on the planet making its orbit very elliptical instead of nearly circular). My simulation failed to backup the results and I spent more time analyzing my simulation than anything else... :p


    Already done:

    OrbitSim Project (1.9MB)
     
    krougeau and barrycook like this.
  5. Abdullah.Ahmed

    Abdullah.Ahmed

    Joined:
    Sep 22, 2009
    Posts:
    18
    Badass Higgy..Badass!
     
    barrycook likes this.
  6. Mutos

    Mutos

    Joined:
    Jan 12, 2010
    Posts:
    9
    Hi all,


    Thanks for your replies !

    Higgy, I tried your link, but I see only the windows and black background but nothing movig in it except time figures displaying. But indeed I would much like to see how you did it, it's quite impressive ^-^ I downloaded your project ZIP, but I just can't figure how to open it with Unity...

    I agree with your remark about the scales. What I want to do is not, however, to simulate the orbits themselves. I only intends to display fixed elliptical orbits read or generated from a XML file. They would only act as a background for starship commerce, travel and combat using a mix of Homeworld and Freelancer interfaces. So I may not need elaborate physics such as what you used.

    I thought about using actual mks units internally coded in double precision, then translating all coordinates using the camera as origin, then converting them to floats for passing them to the display engine. That was what I used years ago for the old VB editor whose screenshot I displayed. With all singles, it was not precise enough when multiplying distances and other values, but whith doubles it worked fine. I also came up with a zooming system that gave a wonderful sense of scale. The project is downloadable here.

    However, that would mean not to make use of Unity's physics and collision engine, which features I would like to use, if only for collision detection !

    However, for now I've not even issued a single project under Unity. In fact I don't know where to begin ^-^ Maybe displaying a single star with elliptical orbit with real-world units and time control could be a first goal ?
     
  7. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Higgy this is truely impressive, I like it very much.
    I was never good at physics and all that solar system stuff, I like what you have done with this, it actually is helping me in my current project I am working on where I was having some bugger issues with the trails.

    Thanks
     
  8. Mutos

    Mutos

    Joined:
    Jan 12, 2010
    Posts:
    9
    Hi Higgy,


    I've ran your demo scene but to no avail : it displays the background with the 4 windows and nothing more.

    Now I'm trying to get it display something meaningful on my machine. For now it bugs out in LoadSimulation. It has something to do with parsing the XML and with the float format.

    I'm currently testing, trying to found out what goes on and learning the fast way in the process. It's a fine way to get started to Unity ^-^

    EDIT : got it. As I thought, it was a regional settings issue. Juste changing the separator from . to , in the XML file did the trick. But it was interesting to see how the whole thing was setup, and to track the issue to its source.
     
  9. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    Thanks. :)


    Yeah, for me the decision to use our physics features to drive the simulation really forced my hand in terms of doing something with the units (as described above). Given what you said above it may not be such a pressing issue but one to think about none the less as the use of really large values may still result in precision issues (z-fighting, calculations, etc.). So give it a go, but be ready to adjust if/when you see problems (hopefully you'll write the code to be flexible enough to handle that).


    I'll have to give that a look later as it seems Windows only and I have a MacBook Pro here at work (I'll check it on a Windows laptop at home tonight).


    There it is, even if you're not using physics the way I did you'll be using it in some way, and that may be the bit that forces you to adjust your units. :)


    I'd honestly encourage you to work through the tutorials and whatnot to get a solid sense of working in Unity first. I know that's not as sexy and cool as jumping right into things (something I'm very prone to doing with new software), but it might save some headaches. After that I think that what you outlined above would be a good start, perhaps going with real-world units with readiness to convert to something else as needed.


    Let's just say that I grew frustrated with our trail renderer when making this game. It was another classic case of spending time actually doing stuff with Unity (an absolutely *key* thing for me to do regularly) and hitting an annoying and confusing wall... :p What's my point? I too get stumped and frustrated with things like you guys do at times and I'm here trying to commiserate alongside you. :)


    Dang, that's just not something I thought about when "knocking this out" (it was roughly a day or two of work over a weekend). I'll note that and see about updating the project to better handle various separators. Thanks!


    Keep the questions coming about my OrbitSim if you have more, otherwise I hope that we've all got you well on your way (post updates!).
     
  10. dpentecost

    dpentecost

    Joined:
    Apr 3, 2009
    Posts:
    136
    I've got a variation on this demo that I'd like to share - star background, camera swoops through on Eric5h5's camera track script - but I find that while it plays fine in the editor, any build whether web or standalone shows no simulation running. Just a black background in the original demo, a starfield and camera moves in mine.

    I'm on a Mac, running 2.6.1. Higgy, have you tried building the demo? Does it work for you? I did see that it had to update the assets. Maybe you are running it on 2.5?

    Hope you can figure out what I am seeing, or not seeing. I'd like to show the little space ride I have created. To infinity, and beyond!
     
  11. Mutos

    Mutos

    Joined:
    Jan 12, 2010
    Posts:
    9
    Hi dpentecost,


    When you built the original, does it run ?

    I had with the original the same issue than you with your variation. The cause was a regional settings issue.

    There's not much chances it's that in your case, because otherwise the original wouldn't run on your machine either, but every idea might trigger another...
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Try using

    Code (csharp):
    1. System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
    to fix the "," vs. "." thingy; maybe that will help.

    --Eric
     
  13. Mutos

    Mutos

    Joined:
    Jan 12, 2010
    Posts:
    9
    Hi Eric5h5,


    Thanks for the hint, I'll try it, it might be the good way to go.

    I'm now building my first app to mimic what my old VB code did, using the lessons I learned from tutos and HiggyB's sim.

    I first crash-ran through some tutos and learnt many things on the Unity feel and daily use, so I'm beginning to be at ease within the IDE.

    But the most useful lessons for me were in HiggyB's sim. In fact, what I need is quite far from the tutos, but akin to his work.

    For now I've validated displaying two spheres for the Sun and the Earth, at the right distances and with camera placement OK. Next I'll add camera zoom/rotation around an object and object switching.
     
  14. dpentecost

    dpentecost

    Joined:
    Apr 3, 2009
    Posts:
    136
    Mutos - Both the original and my variation will run in the editor. Neither runs in a build.

    Eric5h5 - sorry, I need more than a hint. How would I use that code to change regional settings if I wanted to try that? Does it go in the XML parser?
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You should be able to use it pretty much anywhere, since it changes the settings for the current thread, of which there is only one. (Unless you specifically make more threads yourself using System.Threading.)

    --Eric
     
  16. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    And for reference, I built that project well before Unity 2.6 and haven't opened/edited/tested it since. If there are issues then let me know (PM please) and I can see about updating the project and reposting it and the build (which will also include Eric's tweak above).
     
  17. dpentecost

    dpentecost

    Joined:
    Apr 3, 2009
    Posts:
    136
    FYI - For me, that script made no difference - still runs in the editor, in a build everything runs except the simulation.

    To make sure I used it in a useful way - I created a new GameObject, created a new script, cut and pasted the code into the script (but outside the update) and put the object in the Hierarchy.
     
  18. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    Well, to run properly it needs to load the external XML file, do you have that in the expected relative location? (see the code) If you're only testing locally does it work if you post the build to a server? Also, what "build" are you making? My code assumes it's either in the editor or the web player, I don't believe my code will work as-is in a stand-alone build.
     
  19. dpentecost

    dpentecost

    Joined:
    Apr 3, 2009
    Posts:
    136
    Thanks, I think that explains it. And yes, I have the XML file in the same place as your original. I'll keep tinkering. It's a great toy.
     
  20. dpentecost

    dpentecost

    Joined:
    Apr 3, 2009
    Posts:
    136
    Thanks to HiggyB and Eric5h5!

    Here is a mashup, using Eric's trackcam scripts (and his track, adapted):

    http://www.gomaya.com/glyph/docs/OrbitSim3.zip

    (would not upload as an attachment for some reason)

    Eric's project is here:

    http://forum.unity3d.com/viewtopic.php?t=5898

    You can see the progression of my playing, in the 4 scenes included. The fourth used a different equirectangular image which a photographer named Gadi made available on his Flickr site under Creative Commons Attribution :

    http://is.gd/6kXsg

    Sorry to have hijacked this thread. Let me know if there is anything wrong with the zip or the project. Remember that the scenes will only run in the editor - they will not build for web or stand-alone at this point. Enjoy!
     
  21. aoleon

    aoleon

    Joined:
    May 26, 2010
    Posts:
    22
    Your orbits are circular. How do you make elliptical orbits?
     
  22. dpentecost

    dpentecost

    Joined:
    Apr 3, 2009
    Posts:
    136
    aoleon - that would be a question for HiggyB, who posted the original orbits simulation.
     
  23. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    The orbits in my simulation aren't circular so much as they are all slightly elliptical, just like the real deal orbits. The scale is such that the eccentricity of orbit is exceedingly small but in reality I cast the objects in motion and from there they move under the force of mutual gravitational attraction and nothing more. Being as I modeled my simulation after the inner solar system, using scaled data for the Sun and inner-planets, and the inner-planets do in fact have nearly but not quite circular orbit paths, my simulation has the same.
     
  24. Maker16

    Maker16

    Joined:
    Mar 4, 2009
    Posts:
    779
    @aoleon

    Without having looked at Higgy's code, by his explanation of how he set things in motion, I would suggest tinkering with the initial velocity settings and making them higher. Too high, you'll get a parabolic orbit, and your planets will slingshot out of the system. My guess is, he had a general idea of the correct initial velocities which resulted in the proper eccentricities.

    My orbital sim does not use physics engine at all except for collisions. Everything is calculated based on simulation time and an offset for the angle of each orbit. That way, I can manually set the eccentricity and semimajor axis to shape my orbits. You can use a little physics calculation, though, to take manually set data, such as semimajor axis and eccentricity, to calculate what a body's velocity should be at any given point. Then you would give it a starting position, let it calculate the velocity at that position, and then let the physics engine take over.
     
  25. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    As was noted in my earlier post this is in fact a scale model of the inner solar system using real data (at least real data for each planet at apogee*). My senior year project in college while pursuing a degree in Physics was to write a numerical simulation for an N-body system operating solely under mutual gravitational attraction, so it's somewhat familiar territory.

    *It's trivial to look-up planetary data and get things like the semi-major axis of orbit, the average/slowest/highest speed of orbit, etc. Thus I simply decided that all planets being, aligned radially and at apogee to start the simulation. Again, all using real data, just a mocked-up starting scenario.



    The end point for my demo was to have UI controls that would allow you to adjust the weight/velocity of each body at any time. But alas I don't have that sort of UI in there. :p What you can do is tweak the simulation's initial configuration as you like (masses, positions, velocities) as that data is pulled from an external XML file.
     
  26. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    I just posted a video of my elite style space trader called The Core over in the showcase forum. It features a full galaxy of over half a million stars and planet systems, just figured considering the similar topics you might be interested :)
    http://forum.unity3d.com/viewtopic.php?t=54922
     
  27. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    depends on the platform.
    Normally you would try to remain within the 50k absolute range on desktops if its meant to run on older machines, on mobiles its 10-20k on iOS and 500 on android unless you explicitely enforce the higher end devices.
     
  28. Mutos

    Mutos

    Joined:
    Jan 12, 2010
    Posts:
    9
    Hi all,


    As all things finally come to fruition, we're launching an internship with 3 students from the ITIN school to work on the Stellar System Editor, and we're just about choosing Unity as engine !

    I'll see that they get in touch with you all through this topic, for getting help if need be and for reporting their discoveries to the Unity community during development !
     
    Last edited: Apr 15, 2012
  29. Mutos

    Mutos

    Joined:
    Jan 12, 2010
    Posts:
    9
    Hi all,


    After more than one year of silence, some news from Hoshikaze 2250 and its "Stars of Call" videogame project...

    The ITIN internship using Unity didn't finally turn out a workable prototype. Bad choices at the beginning, that hampered development, bad management of sync between myself, the association, the school and the students.

    But we're not giving up "Stars of Call". We're only giving up 3D for a while...

    Meanwhile, we've found a 2d Elite-like game engine called NAEV, an open-source initiative just fit for what we need at this stage. It also has limitations, the larger being, that systems are not to scale and not moving, they're more Freelancer-like in structure. But it allows us to prototype our universe's global structure, factions interactions, interstellar commerce, combat balance and scenario generation using an excellent events and missions toolbox and extensive Lua scripting.

    So for now the game works well as is, we have so far nearly 2000 systems with 200 planets, some 40 factions, 25 playable ships, and some missions and events to bring life to the world as the player roams through it. Of course, there are still many things to develop, extend and balance, and this is but a stage in the "Stars of Call" development process.

    I must add, that the videogame, while remaining on top 5 of our priorities, has fallen from the 1st place. We're publishing our first novel with a pro publisher in June, 2014, this has prompted us to resume work on our 4th short stories book, and we recently found a comics artist interested in taking our first comic project, now due for mid-2015. It is of notice though, that having the ingame map at hand helped a lot the novel's author to plan the "road movie" aspect he wanted for the story...

    From all our investigations, we now have a fair list of possible 3D engines, each with its pros and cons, but for now no choice defined, the time is not ripe. Once we'll have well-established printed works and a refined enough 2D game, we'll shift focus back on the game going 3D. Then, we'll recruit 3D people and make a short list of 2-4 engines. So the final choice will depend on both the engines' features sets and the skills we'll be able to assemble.
     
    Last edited: Dec 29, 2013
  30. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    383