
Preamble
I thought I'd write a postmortem for my compo entry, since people seemed to enjoy the effects, and I was quite happy with them myself. In addition, I also learned a lot and pulled off some elegant tricks this dare, so I wanted to share the development process with anyone interested. The development was also quite hectic, and I figured it would also make a good story.
Zero Hour
Before the dare started, I had a couple of game ideas for some of the themes among the final voting stage (namely for "only three colors"), but I was quite stumped thinking of a concept for theme that won ("The more you have, the worse it is"). I sat and thought for a couple of hours, and nothing came to mind. I decided I'd have better luck in the morning, and got an early night to start work earlier the next day. After I awoke, I only really had a vague idea of what to go with, but decided it was good enough to start.
Original Intention
The original idea was based of the predator-prey ecology of national parks (see Yellowstone), where wildlife officials introduce predators when a species becomes overpopulated. The game would start with bunnies, and the player would have to introduce predators (such as wolfs) or rivals to control populations. Too low or too high a population you'd lose.
I thought the game-play should follow the old nursery rhyme of The Old Lady Who Swallowed a Fly. Each time you introduce a new species to the population, things get a bit crazier, and each new predator would get odder and odder. I didn't really have a solid plan for how things would tie together, but decided I postponed working too long, and wanted to get started.
"Wouldn't It Be Nice" Design
Instead of a solid plan to follow, I sort of just winged it. I thought it might be cool to have the game-play on a globe. So, I opened up blender, created an Ico-sphere, and extruded some areas and colored them in. I ended up with a pretty nice low poly planet. I ported the globe into Unity and pointed the directional light at it.

It looked pretty darn good! While playing around the the direction, I ended up with a neat little mock day night cycle, so I wrote a quick script to emulate my mouse movement. I decided on 1 second being equal to 1 hour, and an essential game-play mechanic was born, unbeknownst to me. I just thought it would be neat effect at first.
Now that we were in space, I needed stars in the background! I didn't want to create a whole 6 sided sky-box, so I opened up Paint.net, made a quick 512x512 image, and added some white, blue and purple dots. I then applied a glow filter, which makes the texture a bit more convincing. At first, I played around with a parallax scrolling effect, where a simple quad would follow and always point at the camera, but since the camera could rotate around the sphere, the quad's texture would warp and stretch instead scrolling properly. Instead of trying to fix the math, I made another quick ico-sphere, inverted the normals to face inward, attached the texture to it, tilted it, placed it around the globe, and a credible space background appeared.

Next, I figured if I wrap a similar ico-sphere around the earth, I could make a convincing atmosphere. So I created yet another low poly sphere, rotated it and generated a quick cloud render in Paint.net (seen below). I set the texture alpha to grey-scale, and applied it. The problem was, I needed a transparent cutout effect, which Unity doesn't have by default, so, I created a custom surface shader that applied a cutout effect before applying the alpha and added a scroll effect to give the clouds some movement. The shader didn't apply shadows the way I wanted, so instead of experimenting/debugging/researching, I just duplicated the cloud's sphere, rotated it slightly, and applied the same material, but tinted black, to emulate the clouds' shadow passing over the planet.

In-between, I started work on the bunnies. I made a quick simple bunny drawing from a photo reference, and attached it to a quad that always faces the surface's normal. Since the model is so simple, and the amount of identical bunnies that would appear onscreen, I used Unity's GPU Instancing for the bunny's material. It really made a difference for a good, well preforming WebGL build!
Next, I thought of how the rabbit's path-finding would work on a sphere. I decided the easiest way would be to just rotate the bunny on the planet's axis, rotating towards wherever it needed to go. I ended up with the following quick bit of code. For debugging, I had the bunnies follow the cursor, which ended up being a game-play element, but more on that later.
// By default, move to the upper right
Vector3 rotAngle = new Vector3(1, 1, 0);
if (this.transform.position.x < goalLocation.x) {
rotAngle.y = -1;
}
if (this.transform.position.y > goalLocation.y) {
rotAngle.x = -1;
}
transform.RotateAround(earthPivot, rotAngle, speedMod * Time.deltaTime);
The method worked well enough for the time constants, but issues would arise. Mostly, bunnies would pass through each-other and buildings. I didn't mind the buildings so much, but the bunnies would clip inside each-other, making a hundred of them look like a single rabbit. So I rushed writing code to get around this, which ended up being buggy, causing them to sometimes get stuck and stop moving altogether.
In hindsight, the problem wasn't the bunnies clipping, but the pathfinding being too simple. A more fully functioning, correctly working pathfinding/collision system was the way to go instead of applying "the patch," but inside the time constraints probably not as viable.
Here Comes the Sun
I had already implemented the day/night cycle for aesthetic reasons, but it didn't occur to me until later that it would make a good game-play mechanic until I started to implement the economy system.
The game needed a way to manage each species population by placing buildings and whatnot, and the most obvious way to implement it was a classic money system. I figured placing down buildings as money generators would make sense, and would be quick to create. The first thing that came to mind was a solar panel, and soon the idea for power to be only generated while in sun light. Hence, a unique visual effect became a unique game-play element as well!
I had a few ways of detecting if an object (i.e. a solar panel) was in daylight; one way is to use a ray-cast from the sun's position and point towards the object. If no other object is in the way, then the object would be in light. The problem was, due to the buildings' exaggerated scales, if an object was near the poles, it would always hit, even if it wasn't in daylight. Plus, the game actually uses a more geocentric like model for its system (it's simpler that way), the planet stays still, while the directional light is what gets rotated (but also doesn't move). I could have done some math to get where the sun's location would be, but there were other options that didn't have the same drawback at the poles.
Another way was to use a render texture pointed at the object and find the object's pixel color value, where a darker value would be in shadow. Alternatively, I could use Unity's Renderer.lightmapIndex/realtimeLightmapIndex to determine the value instead. I didn't use these options since it seemed too involved to experiment with in the time frame of the Dare; plus, it seemed like overkill for a game with a single light source.
Instead, I simply used a dot product, similar to what a diffuse shader does.
```
float InDayLightDot() {
//https://docs.unity3d.com/ScriptReference/Vector3.Dot.html
//For normalized vectors Dot returns 1 if they point in exactly the same direction, -1 if they point in completely opposite directions and zero if the vectors are perpendicular.
//Forward vector of panel faces the earth, hence, a positive dot value == in sunlight
return Vector3.Dot(this.transform.forward, Sun.lightDirection);
}
```
The method worked tremendously well; it was quick, elegant and simple solution! I didn't have to worry about walls, distance, or location, just if the sun was pointing at the object's side of the planet, which made it less involved then the other methods. Since the planet has no tilt, both poles are shaded in darkness longer then the rest of the planet, the dot product check didn't account for this, so I added a manual height check and gave a little bit of bias (dot >= .2 //instead of 0), which was a quick and easy hack.
If I ever expand the game, this system might need to be tweaked/replaced, but it was a great little trick for the dare.
To finish up the building portion, I simply used camera.ScreenPointToRay, and spawned an instance of the selected building from where the mouse clicked, facing the hit's normal. I included a layer mask to filter out everything but the planet's collision sphere in the cast. For ocean detection, I used a separate collision mesh consisting of just the sea portion of the planet instead of fiddling with material detection.
To generate money or bunnies, I simply used Coroutines to call the generate function every x seconds on each instance. Since most object are placed at different intervals, it's actually pretty cheap (for performance) since most buildings will call the routine on different frames, meaning no massive hits.

End of Day One, Beginning of Anew
Towards the end of day one, I had a pretty game, but no actual game-play. I realized how long implementing the ecosystem would be; including more animals, events, and interactions wasn't feasible in a single day. Even if I managed adding cramming those required features in, I'd need time to tweak and play-test to actually make it fun, balanced and compelling.
So, I started thinking of ways to cheat bunny overpopulation into being a negative characteristic, and figured a hard cap would work. After x number of bunnies, a UFO would come down and destroy the planet. The wolf population would help control the bunnies, but would swap from a population to control to a building object you would place instead (wolves were eventually scrapped due to time).
After giving it more thought, I figured "why not turn it into UFO defense game instead?" At this point, I had the planet, controls, placing buildings, and bunny AI somewhat working, I just had to finish up the building code and implement the game-play features. So when I awoke, I cleaned up the building placement, implemented the building code, repurposed what didn't make sense anymore, and got to work on the UFO portion of the game.
As stated before, I had the bunnies follow the cursor for debugging purposes, but it quickly seemed like a good game-play mechanic. One could control where they were on the screen and protect them from the UFOs. I also figured since the theme was "The more you have, the worse it is," they would block the player from building on-top of them, making it harder to build the more you had (which now that I think of it, was obviously problematic, but more on that later).
I figured each full rotation (each day) would be a good way to spawn events such as disasters, but since I morphed the game into a tower defense, I figured each day should spawn UFOs instead. To spawn them, I decided to just pick a random direction 32 meters away from the planet, and have them float towards it. At first, I started to implement my own function, but found out Unity had a built in Random.onUnitSphere property, which made this much easier. I simply multiplied the value gotten by 32, and Instantiate the UFO at that position and facing the earth, then send it hurling towards the bunny infested world. While the UFO descends, it casts a short ray towards the planet, and once it hits, the UFO stops moving towards it and the AI kicks in while also turning on the death ray.
At this point, watching the clock tick down, I decided to start going for quick fixes instead of clean code with the limited time available. I copy and pasted the solar panel class for the windmill, house, and carrot patches. For the UFO AI, I copy and pasted the bunny movement code with some slight tweaks to adjust for their raised nature. Although I cringe at the sloppy code, without copying, I wouldn't have submitted on time.
While working on the UFOs, I also started working on the guns (What's a defense game without guns, after all?) which simply targeted the first thing in range until it has left or died. I also added the main menu, UI, and other tidbits, barley finishing before the compo ended. With no time to play test, I figured being too easy was better then too hard (a problem my other entries all have), so I lowered the UFO speed, and put the cash rates at pretty generous levels, and submitted.

Lessons Learned
As one has read, it was a fairly tumultuous two days of development, with features being created on a whim, and the design changing fairly radically. Under the circumstances, it came out fairly well. I'm glad I took risks and tried things I haven't before. It could have went either way in the dare, lucky I was able to re-purpose so many elements, so I'm happy I ended in a finished entry!
I was surprised how well my WebGL build runs (especially compared to my previous entries)! I'm assuming it's partly due to improvements made by Unity, and partially due to me gaining more experience and knowledge limiting draw calls. As stated previously, I made sure the rabbits and buildings where GPU Instanced, and I tried to limit the amount of materials in general, reusing materials when I could. Since I went with the low poly look (quick to create appealing looking assets, great for a dare!), I used solid colored materials which can be reused on different models with the same color. But, if the model had two or more colors I took the time to create a UV map and used a texture instead to avoid the very costly expense of having a model with multiple materials. Hence, I balanced speed of creating an asset (important for a compo) with the speed of drawing it (important for performance). Although, I did cheat and use multiple materials for the globe, as I didn't want to go back to an early asset to optimize.
For my next dare, I'll be sure to leave enough time for play testing during the development, go with a simpler idea, and actually write out a small design doc instead of molding the game while developing it. I'd also try and go for a more polished and finished product, instead of a rougher prototype style my games have been, as they seem to do better and get more exposure, although, I've said all this before! I tend to enjoy trying new things and ideas, and I get carried away, forgetting my aforementioned rules. So we'll see!
Thanks to everyone who played, rated, and or commented on my entry so far! Here's some feedback to those comments.
Complaints
Most of the complaints derive from a lack of play testing. I wasn't even able to play the game until after I submitted it! The game wasn't in a playable state until the final hour of the compo, so I was quite happy one could play from start to finish without a crash or bug, yet, some of the problems could have been easily addressed with some testing.
Some found the game to get a tad bit stale, which I can agree. Once you place enough defenses there's not much else to the game other then waiting twenty-eight days till the finish. With proper play-testing, I would have tweaked the values to make the game more challenging, added a cost each time a gun fires a bullet (or a limit), and allowed the UFOs to destroy buildings.
The decision to block buildings being created on-top of bunnies seemed to confuse people. Some didn't understand what was going on, and figured placing buildings randomly wouldn't work. I should have made it more obvious, but really, having something that follows your cursor blocking the cursor's main function might not have been the best feature. I should have a toggle to force the bunnies to follow/unfollow you instead. Although, that might have ruined the chaos from managing them. (Fun fact, the carrot patch at one point was going to lure bunnies to it, but, ran out of time!)
I also found out people don't read help menus! Which should have been quite obvious, as people usually try and move from game to game. A quick in-game tutorial would have been a better option (and would have made the game-play easier to understand), but also more time consuming to create, and tutorials bring their own set of issues.
The game didn't have any audio either! I created a small UFO sound effect (it's still in the source code) but I didn't have time to implement it, or create other sound effects. If only I had an extra hour! The UI was also rushed, so I didn't have time to properly test it at differing resolutions, or pretty it up. So I allowed people at lower resolutions to hide the buy menu, but the menu was too small at super high resolutions! Using non default font (I used a Futura style called Fax Sans was a good choice, since it gets rid of the cookie cutter look of default Unity menus, while being simple to implement.

Complements
People seemed to really enjoy the visual style! I detailed how I accomplished it already, but I'm glad people seemed to really like it.
Some found the game innovative, which I'm proud of. I tend to use dares as a motivation to actually build and finish something, and use bending the theme as a good exercise in creative thinking. The globe was a unique aspect, not only visually, but game-play wise as well. The feeling of being attacked on a wide scale, and defending the entire planet also helps. Looking after a populous instead of a straight line also differentiates itself from tower defense games. I'm glad it came together in the end, and people found it fun.
I also got a few commenters who enjoyed the story I wrote for it. As you can tell, I enjoy writing (I wrote way more then I was expecting for this postmortem) so it means a lot that people found it humorous and liked it. The story is small addition to the game, but I feel it adds value to be given a background to the world. Writing in second person is an interesting style that works well for games, as it engages the player, putting them in the game's universe.
What's Next?
If I decide to continue development, the first thing I'd do is rewrite the game from the ground up, with a proper plan this time. I'd also add more simulation aspects to the game, bunnies would be selected and used to construct and control the various buildings (maybe like in Banished or an RTS?), and you'd have to micro manage them. Another sim addition might be tech-trees for additional building unlocks as well. I'd also like to add multiple planets you could explore / control, and possibly even terrain forming and terraforming features. Although, I'm not sure if each planet (or group of planets) should be separated by levels, or if it'll become a continuous game where you'd need to build rockets to find new worlds to conquer.
For now, these are just ideas. I don't have a solid plan to continue development, but if I the game gathers interest for some reason, or does well in the ratings, I may consider it.
Conclusion
Whew! I wrote more then I expected too!
I hope you found the postmortem an interesting read! I learned a lot from making this entry, and I'm glad I was able to share my thoughts and findings. If you have any question or remarks, feel free to leave a comment on the post, and I'll try my best to answer. If you'll like to try the game, you can play it here.
Thanks for taking the time to read the postmortem, and for checking out Perigee!