Orbital Bodies: More information !

Next step on my list was to add some UI to the simulation to display various stats on the orbital bodies. I started off with creating a panel that would display the name, mass and velocity of a selected body. I created a new component called “GravityInfoUI” that would manage the information displayed on the panel. Selection of an object is done by doing a screen to 3D space ray cast and seeing if the ray collides with any object in the simulation.  When a collision is detected with an orbital body the UI component stores a reference to it’s RigidBody component and pulls data directly from it to display on screen.

As can be seen from the above clip it’s a little trick to click on small fast moving bodies to get their stats, so it seemed logical to add a pause button. That is simple enough to accomplish using Unity3D. I added a new Pause/Unpause button on the top of the screen and created a public function on my UI component called PauseUnpauseSimulation. The function when called simply switches the Time.timeScale value between 1 and 0, where 1 is the normal simulation speed and 0 pauses the simulation.

Last time I made a game on unity for a game jam I uploaded a build for unity player to my website. But unity has since deprecated support for the unity player and has moved over to WebGL. Making the build for WebGL was simple enough but hosting it was problematic, I tried uploading it directly to my website, which didn’t work. Diving into forums showed other people had had similar problems, I tried uploading a build to my google drive and to OneDrive, also tried a wordpress plugin, non of which seemed to work.

Finally found a website called itch.io that allows you to upload your WebGL unity projects as a zip file and it takes care of the rest. I’ll keep an updated version of my simulation posted there if anyone wants to try it out. link