Hello everyone, Evan here for the first time in a devblog. While Tyler and Victor have been working to get the new user interface implemented and looking fantastic I have been tying up a few loose ends. We thought it was really important that all the planets, stations, and asteroids that you can send your brave little colonists to were visible in the skybox you see. This makes the world, or I guess solar system, you are in feel much more alive. Even something that seems this straight forward is never without its challenges though.
The first challenge of course is making a flat image like the skybox background feel like it is completely surrounding the station. There are a couple of approaches you can take to solve this issue though. You could create two instances of the background and place them side by side while scanning them with a camera, after the first image is no longer being shown you just move the first image to the end of the second. The problem with this is not only do you have to keep two fairly large images rendering, eventually the positions of them will just get silly because you have to keep moving them.
The second approach still needs an extra moving part to make this work, but instead of another image we just need another camera.
With this method we just need to make sure that when the leading camera leaves the edge of the skybox it gets repositioned a specific amount away from the other camera. This specific amount actually happens to be the overall width of the skybox. This method is also very helpful because not only does this image "move" but so do all the other things that are shown in the skybox.
3d System, 2d(ish) Skybox
It makes sense that if you are to spawn a cluster of space objects you would do it in a 3d space, it would seem bizarre to do it any other way. Once all objects are placed though you have to somehow convert everything into coordinates that you can show the player in a skybox.
You also have to take into account that any object you spawn has to be visible from the station or what is the point of going through all this work. So you need to ensure there is an easy way to tell other object to pick a new spawn if they obstruct another object.
The First Approach
My first approach was to use the X and Z position of the spawned object and calculate its angle to the station, this would give me a value that I could use to place the object on the X axis of the skybox. Using its Y position I could then figure out proportionally where it went on the Y of the skybox.
Now I know what you are thinking Evan you genius. Well that's where you are wrong, here is another example with the same amount of planets spawned.
The asteroids that are covered up by others just happen to have the same angle from themselves to the station. Now this would really happen in the real world, but like I said above we would really like all the planets to show up in the skybox. I also mentioned we could just stop them from spawning if they were going to be blocked. The problem with this system is that for each and every space object spawned you would need to check if it had the same angle and any other object then if that was true see if the Y values were too close.
A New Approach
Instead of making comparing all these spawning skybox objects a hassle of trigonometry, I decided to try a system that would let us just compare two coordinates to see if they would interfere with the other objects. Instead of calculating an angle for its X position in the skybox we just proportionally find its value like we used to with the Y position. And with the Y value we base if off the objects Z position in the solar system instead of its Y. After we do this it is trivial to check if the spawning validity of new objects, if their X and Z positions are too close to any existing X and Z positions we can just get a new random position.
I did say the skybox was only 2d(ish) thats because they do have Z values assigned to them when they placed in skybox. This value is used by other components to resize whatever the object is based on how far away they are from the station. It is also worth noting if the station position is ever moved this whole system is equiped to display that skybox differently.
If you make it to this point I appreciate you, actually I appreciate everyone who has supported us. They were able to give me a once in a lifetime opportunity to leave the dead end job I was working at to do something I truly love. I know that once Starmancer gets into all of your hands you will see just how much passion this whole team has for it, and game development in general. If you want to shoot use a message or have a question stop by our Discord. Thank you all.