Search Unity

Games Rocket Simulator [ Need Beta Testers]

Discussion in 'Works In Progress' started by Stef_Morojna, Aug 6, 2017.

  1. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280

    So what is this game all about?
    This game is about space explorations, its about building your own rocket, and going out to explore and see whats out there, all while following real life physics.

    Controlls:

    Click on parts to use - activate them.
    Use l
    eft - right arrow keys to turn.
    Use up - down arrow keys or Shift - Ctrl to adjust throttle.
    Spacebar to toggle throttle.
    ( Pc controls are just a place holder, the game is for mobile)

    Download link (Pc and Mac): https://www.dropbox.com/sh/guvsulcwluk1y6h/AABVYJmact4TAoku9h9ZUA0Ca?dl=0

    I really ask you guys to be brutally honest with your feedback, because the sooner I know the games problems, the easier is it for me to fix them.

    Some screenshots:

    upload_2017-8-5_23-0-12.png upload_2017-8-6_13-36-12.png
    upload_2017-8-6_17-25-59.png upload_2017-8-6_19-15-27.png
    upload_2017-8-5_23-7-36.png

    Gif's:
    https://thumbs.gfycat.com/AncientVibrantDaddylonglegs-size_restricted.gif
    https://thumbs.gfycat.com/AnguishedVariableDogwoodtwigborer-size_restricted.gif
     
    Last edited: Aug 22, 2017
  2. mzpromom

    mzpromom

    Joined:
    Aug 6, 2017
    Posts:
    6
    it blacks out after reaching speeds 382 but come back on at speeds of 392
     
  3. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280
    Could you be more specific when-how it happend? were you time warping? what blacked out? (maybe it was just the background going black because you reached space?) A screenshot would also help.
     
    Last edited: Aug 6, 2017
  4. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280
    I did find a bug where time-warping under really specific conditions would "teleport" you about 200s into the future (fixed it already), however I don't think that is the same one you are talking about.
     
  5. MMOInteractiveRep

    MMOInteractiveRep

    Joined:
    Apr 7, 2015
    Posts:
    88
    So basically your own remake of Kerbal Space Program?
     
  6. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280
    I would say more like a simplified version for mobile, but yeah more or less that.

    Btw its kind of interesting how it got here.
    So around 9 months ago, I applyed for Squad, and as a demonstration I made a orbits simulation program, so while I was waiting for a response ( I don't blame them for never responding, now that I think back about it, my apply was pretty bad) I kept adding stuff to it, until it got to a point where I just decided, eh I will make it into a game.
     
    Last edited: Aug 7, 2017
  7. MMOInteractiveRep

    MMOInteractiveRep

    Joined:
    Apr 7, 2015
    Posts:
    88
    Awesome! Well good luck with it. We really need more high quality Space Games to get people back interested in Space Exploration while we wait for Orion's first manned flight!
     
    Stef_Morojna likes this.
  8. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280
    Im more of a SpaceX - Dragon2 guy :p, but yeah space presence really should return.
     
  9. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280
    I added a few new things:

    New Mars terrain ( mostly made of mountains, dunes and canyons).
    Parachutes that attach on the side.
    Closest approach markers ( so now its not just guessing when you will get a encounter).

    upload_2017-8-10_0-10-4.png upload_2017-8-10_0-12-28.png

    Valles Marineris
    - Mariner Valley on mars:
    upload_2017-8-10_0-9-31.png
     
    Last edited: Aug 10, 2017
  10. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    This is great.

    Are you aware of the existence of 'Simple Rockets'?

    I've also once solved orbits stability with Runge-Kuta and temporal snapping, what are you using?

    To 'weld' the parts together, I'd recommend fixtures on a single body and using something like a stiffness matrix so the rocket parts are held together rigidly (no wobliness) and you can still apply forces to get points where it should break. I once tried to tell the Squad guys about this too, especially because there's a nice .NET library they could use for structural analysis and would solve the problem with wobbly rockets, but they didn't care about that too... KSP is a great game but that limitation prevented me from enjoying it.

    How are you dealing/planning to deal with floating point inaccuracy?

    Regards
     
    Last edited: Aug 10, 2017
    Stef_Morojna likes this.
  11. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280
    So about 'Simple Rockets'... yeah I found out about it when my game was at around 70% made... almost made me quit.

    For the orbits I simply use Kepler's equations, you basically give it a time, and it gives you the position-velocity etc at that time. Its 1000% precise for billions of years ahead.

    For solving the parts wobbling, that's actually a really great idea!
    However I don't think I will implement it right now. The parts system right now is a bit... limited, the problem is, how parts interacts when placed next to each other is more or less hard scripted in (like how landing legs "stick" to fuel tanks, or engines get covered when something is placed below them), so i'm planing to redo the whole parts system in something like a 1.1 update (First big update after game is released), so I will wait and implement the wobbling solution when i'm already reprogramming the entire parts system.

    Also just a quick question: What would you say is right now the most annoying thing in my game? Like what would be #1 thing to improve the game?
     
    AlanGameDev likes this.
  12. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Don't let Simple Rockets discourage you!

    So since you're using that approach, do you plan to have a circle of influence like in KSP? The beauty of solving with a temporal algorithm is that n-body systems are 'free', if other masses are capable of influencing a body enough to pull it out of its 'trailed path', which is of course an arbitrary value, then you get normal Runge-Kutta again, until you 'trace' another path you can snap to. The only problem with this approach is that you need some intelligence in the code to determine to which object your path is anchored to, but that's easy to solve.

    Regarding the wobbling, that's the best way to solve that issue for good in my opinion. In the mean time maybe you could increase velocity iterations. Unfortunately I don't think Box2D allows fine control over that (per joint/body) like other engines do, so increasing it globally is probably the only way to make the rockets more stable if you have problems, especially after you add some parts with high mass ratios.

    You didn't address my question on floating point inaccuracy though :p. It's not possible to do something like this with a naive approach using single precision floating points. You'll need to have some way to workaround that, the most common solution is origin shifting. I'm not aware of a Box2D port that uses 64 bit floats, but in theory increasing the precision of your units could allow you to go with a bruteforce approach. I'm not sure if 64 bit is enough for a solar system though, and while you could use say Velcro and use even larger data types, like 128 bit, it's certainly not going to perform fast enough since it's 2 accesses on a 64 bit machine.

    Good luck with this! :)
     
  13. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280
    upload_2017-8-10_2-42-47.png
    Yes i'm already using spheres of influence.

    Also
    This one was one of the most complicated problems to solve... There is just so many things that can go wrong, so many combinations.
    And getting the encounters predicted correctly... that thing took me weeks...

    Also
    I will try it, I just hope it wont cause performance issues on mobile.

    Also
    Sorry I forgot this one.

    So what I do is I have a "Offset position" and a "Offset velocity". The rocket never goes further than 1000 units from 0.0, when it gets close to the edge, it teleports the rocket back to 0.0 (while also moving everything in the game, including the planet with it), you can't see it from the players perspective, but here is a old gif that shows whats going on.
    hdghd.gif

    Because the offset is saved in a Double3 (a custom class I made that handles Vetors3 but with doubles instead), I can go up to light years in distance before I start getting float precision problems.

    For the position I do the same, but add a velocity offset.

    Basically as soon as the rocket moves faster than 25m/s, I set its velocity to 0.0, and start moving the planet instead, that way even when moving at high speed (aka fake speed really, the rocket is almost still), I still don't run into float precision issues.

    Velocity offset.gif

    As you can see, as soon as velocity hits 25m/s, I remove 50m/s from it, making it -25m/s
     
    Last edited: Aug 10, 2017
    AlanGameDev likes this.
  14. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Yep, that's what we call "origin shift".

    It seems you have all the basis ready, just need to add the actual game content now.

    The only recommendation I'd do is to somehow fix the wobbliness since that really ruins the fun because it limits your creativity. I am working on a game that involves building airplanes and I'm using structural analysis for the stress as opposed to physics engine 'joints', it really works much better because no matter what structure you build it'll be 'solid' and you can do it asynchronously on another thread with the help of buffers for the impulses and results (C# has concurrent collections in the stdlib). This is more of a recommendation of course, I don't even know if you're planning to allow massive structures.

    There are some permissively licensed FEA projects on GitHub as well as a rather fast stress solver in Nvidia GameWorks these days, but it's 3D. These days you can also use the Intel MKL for the math with the new license model.
     
  15. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280
    I think I found a good solution. What I did is make each "connected group of parts" have only 1 rigidbody2d, and each part is only a collider of that rigidbody2d.

    Pros:
    Absolutely no wobbling, no matter what you do (so rigid it sometimes looks wrong).

    Huge performance improvement, physics calculations were reduced by like 10x, I have tested it with up to a 1000 parts and still have 60 fps.

    A lot of stuff was simplified, for example before I have to calculate a lot of things for each individual part ( like center of mass, that was crazy hard and expensive to calculate)

    More direct control over stuff like center of mass, center of lift, etc.

    Cons:
    Rocket is as rigid as glass, it sometimes just looks weird. You can have things like this http://i.imgur.com/iXCj0C7.png be perfectly stable, when it really should wobble itself apart...

    High speed collisions look weird... the rocket just kinda bounces off and acts as 1 big solid piece, it doesn't wobble and tear itself apart like the joints system would.

    No wobble.gif upload_2017-8-13_19-49-15.png
     
    Last edited: Aug 14, 2017
    AlanGameDev likes this.
  16. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280
    Last edited: Aug 22, 2017
  17. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Awesome progress on this!

    Are you calculating the correct mass and CoM for the rigid body that holds the parts? It could get a bit tricky to update that for fuel burn and such, but you can generally do that naively, just store the weights of the parts and recalc the whole shebang often. If you're planning to have really huge systems you may want to go with a better approach though.

    That's why I've mentioned using structural analysis to solve that, the basics would be assembling a stiffness matrix and applying the external forces (e.g.: thrust and impacts), and solving it. That way you would get the points where it should break, or even 'bend' but that's a bit harder and imho doesn't necessarily improve gameplay. Centrifugal force could be a bit hard too, but you can approximate it just by getting angular momentum of the body and calculating the distance of each part to the CoM and applying the force accordingly.

    If you're not familiar with that concept, take a look at Nvidia Blast. It's 3D but you could use for 2D, and it has all of that, recently the stress solver was decoupled from the PhysX extensions, and it has a nice C API you can easily Pinvoke.

    That is the only adequate way to solve the problem. All vehicle building games I've tried so far fail miserably and limit the creativity because no one solved that problem decently yet (except me :p ). With a solution like that you'll be able to build for example huge space stations without any wobbliness or performance problems.
     
  18. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280
    I just use a ReclaculateCenterOfMass() function, that when called, tells the vessel to recalculate CoM and mass at the end of the frame. That way even if I take fuel from like 10 fuel tanks, it recalculates only once.

    Doing it is also not expensive, because it just uses the parts local position.

    Actually... whatever here is the code :p
    Code (CSharp):
    1.     public void UpdateCenterOfMass(){ // Updates center of mass at the end of a frame if necessary
    2.  
    3.         float newTotalMass = 0;
    4.         Vector3 sumedPositon = Vector3.zero;
    5.  
    6.         for (int i = 0; i < parts.Count; i++){ // Loops once for each part
    7.  
    8.             newTotalMass += parts[i].mass;
    9.             sumedPositon += (parts[i].transform.localPosition + parts[i].centerOfMass) * parts[i].mass; // Part local position in the rigidbody2d + local center of mass of the part itself
    10.         }
    11.  
    12.         rb2d.centerOfMass = sumedPositon / newTotalMass; // Applyes new center of mass
    13.         rb2d.mass = newTotalMass; // New mass
    14.     }
    If I got it working a 100%, this could be great, but I feel like if I get it working 95% of the time, but it breaks 5% of the time where it should not have, it will get REALLY annoying for the players, and at the end, I don't feel it is even all that necessary for the game.
     
  19. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280
    Some new things that I added:

    Sound and music
    Now the game has quite a lot of sounds, probably close to half of the sounds needed.
    Music is also being worked on.

    New transfer windows markers.
    upload_2017-9-15_2-37-54.png upload_2017-9-15_2-40-5.png upload_2017-9-15_2-41-4.png

    Terrain upgrades
    I have been playing a lot with shaders, terrain generation algorithms with some hand painted height maps on top, and now the terrain is starting to get closer to what I want:
    upload_2017-9-15_2-30-25.png
     
    AlanGameDev likes this.
  20. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    280
    I started adding tutorials, credits and a settings menu. As well as polishing all other menus, adding slight animations to buttons to make everything flow better etc, and fixing overall bugs.

    upload_2017-10-5_17-30-4.png
     
    AlanGameDev likes this.