Hour 18 - Planetoids
A full of day of work on Plantasia! And yet, after almost doubling the time spent on the project, it hasn't changed all that much! Although lots went on behind the scenes, the only obvious changes are the introduction of planetoids - alternatives to the flat islands as homes for your plants (which now grow out based on the angle of the ground), and a new day/night cycle which replaces Unity's default skybox solution.
Some Technical Notes
So what took so long? Well, things got off to a slow start when I tried to get going with a simple script to rotate the planetoids in any direction based in mouse input. FOUR HOURS and endless permutations of rotational code later and I got the result I wanted. At first I thought I had bumped into gimbal lock problems, but that wasn't the case. Then I thought it was a problem due to compounding rotations together and introducing subtle issues over time, as described (with solutions) over here. But although that helped, I could still get stuck in a situation where input was creating a rotation in the wrong direction.
Ultimately, for the result I wanted, all I actually needed was to forcibly apply my rotations to the objects transform in world space (pass Space.World to transform.Rotation) around the world axes. The most intuitive rotation of a big ol' draggable planetoid floating in space is relative to the camera (so moving the mouse up, rotates the object "up" according to the viewer), but as my camera is always aligned with the world axes (looking down the positive Z-axis) the simplest solution was, in fact, the correct one for the job. FOUR HOURS, THOUGH.
Anyway, I stuffed all the code in a new component and took the rotational code out of the Island class. With that out of the way I started looking into improving the day/night cycle skybox. The standard procedural skybox that Unity provides gives you a lot for free, but it's not really designed for a scene set in "space" with no real horizon to speak of.
I grabbed the source code for the built-in Unity shaders and tried playing around with the Skybox ones. The procedural one was way more complicated that I really needed. So I created a modified copy of the 6-sided Skybox shader which would blend between a day and night Skybox (there's some similar example code here). That had quite nice results, but I've actually ended up using this free Simple Sky asset from the asset store, which uses scrolling texture offsets to control morning/day/evening/night colours on a sky dome.
Leave a comment
Log in with your itch.io account to leave a comment.