While I'm waiting on a part to get my development PC back up and running, I thought it would be a good time to detail the work I did last week. The goal was simple enough: make it so you can't land on water like it's normal terrain. However the process of fixing this was chasing one thing after another, which then cascaded down into warheads getting some cool improvements for future weapons. [h2]The Problem:[/h2] For physics and damage purposes, water is treated the same as any terrain. The only thing unique about it is that the weapons [i]sometimes[/i] check for water in order to trigger the appropriate visual effects. For the most of the physics and interactions in the game however, water is treated the same as any other terrain. [img]https://clan.cloudflare.steamstatic.com/images//40742388/8bba1be41178535977dc06fe4fc09331526f4fed.png[/img] For a game featuring a plane that is often around water, this isn't really acceptable, and has been [url=https://trello.com/c/neYgOvjB/55-planes-that-crash-into-water-do-not-have-a-water-effect]on the Trello board for quite some time[/url]. The upcoming Arena work was blocked by some required pathfinding fixed (which is done as of the end of last week) so I figured it would be a good time to finally tackle this. [img]https://clan.cloudflare.steamstatic.com/images//40742388/eabbdf82ea59552a5c76c79b2cc072a832b3d652.png[/img] [h2]Just make the water do damage![/h2] First things first, it had to be decided how water should interact with the aircraft. Initially I wanted to have some basic buoyancy model, but that was quickly ruled out due to the terrain not reliably having something [i]under[/i] the water. Sometimes there's actually land just below it, and the possibility of the camera going underwater raises many more questions than I think are worth answering. [img]https://clan.cloudflare.steamstatic.com/images//40742388/7152cf06a10021e420f664f3f09e72b71ac7750c.png[/img] Instead, water should essentially function as slippery lava. You can touch it, but only briefly, and it'll do damage over time. This is preferable to water being a simple kill floor (which is how most flight games treat it) because the player should be able to perform a last minute save in case they happen to touch the water during a botched vertical landing. I quickly added an effect for when the plane slides on water, same as it does on land. Unfortunately when near the water, the "water flyover" effect was active, even at low speeds, completely obscuring whatever was happening to the plane as it "slid" on the water. I've been meaning to optimize that effect anyway so. [h2]Updated flyover effects[/h2] The flyover effect is actually so old that it predates Tiny Combat Arena in its current form, and is one of only a handful of things carried over from the Legacy game. Somewhere along the line, the trigger for the effect became the throttle rather than speed. That was always a quick hack to deal with hovering over water. The flyover effect is now: [list] [*]Tied to the airframe and not the engine nozzle [*]No longer doubles up for twin engine (or twin nozzle in the case of the AV8) [*]Triggered only by airspeed instead of engine state [*]Has a land-based counterpart to kick up dust over land [/list] [img]https://clan.cloudflare.steamstatic.com/images//40742388/691a7ecd2550d2f2c7be6787f9804db7ff96f95d.png[/img] With this out of the way, I could return to handling what happens when the plane touches water. High speed impacts should simply destroy the aircraft, and that already worked using the same code as terrain impacts. What I was most interested in was if you just [i]touched[/i] the water. My test method was usually to come into a slow hover over the water and then touch down. Now that the flyover effect wasn't playing anymore, it looked weird that the plane's engine's weren't disturbing the water. [h2]New engine wash effects[/h2] There's not too much to say about this new effect other than it looks cool and was somewhat inspired by the scene in True Lies where a Harrier takes off vertically over the water. This also involved a couple other minor optimizations to the engine effects. [img]https://clan.cloudflare.steamstatic.com/images//40742388/3f3d27c9d25d6c828d9f10f39750dccc47720969.gif[/img] Now that hovering over water looked fine, I could get back to adding water specific effects for impacting and sliding along the water to replace the dirt being thrown up on contact with the water. Creating the new impact/sliding effects was pretty unremarkable, but when the plane exploded it revealed a new problem. [h2]New debris and weapon splash effects[/h2] When debris hits the water, it just sits there and makes dirt impact effects. The fix was simple enough, making debris time out instantly if they come into contact with water, but having them disappear was pretty anti-climactic. I re-used the water collision impact effects I made for aircraft collisions and it turned out great! [img]https://clan.cloudflare.steamstatic.com/images//40742388/80d5a2922b4de0922f41fcd67aa2d171699a1ff6.gif[/img] However, that wasn't the only effect that needed adjusting. At present, there's really only one VFX used for basically all explosions, including when an airplane explodes on water. It's called "Explosion[b]Ground[/b]Medium" and as you might be able to guess from that name, I meant to create air and water equivalents of it at some point. The biggest issue this effect has, is assuming it's occurring over the ground. When its debris hits terrain (regardless of what it is), it plays a terrain collision effect. Without some really sweeping and low level changes to the game, there isn't a way for a [i]particle system[/i] to tell if it hit water or not, so new explosion effects are needed: an Explosion[b]Water[/b]Medium. While I'm at it, I may as well add an Explosion[b]Air[/b]Medium. [h2]New explosion, updated gear, damage, and camera[/h2] After making new effects for air/water explosions and testing them, I noticed that you could still land the plane on water. So, naturally, I went to change the landing gear to ignore water. Which was nice, but now plane could comfortably sit on its belly on the water. As originally planned, I implemented the damage over time when the aircraft or destructible parts (wings mostly) came into contact with water. When the player died though, the camera was expecting a huge shower of debris. This made water crashes confusing because the camera wasn't really looking at the splash. A new exception for when player dies from water had to be added so you get an alternate view point. [img]https://clan.cloudflare.steamstatic.com/images//40742388/780b745e60348869f03b71b318399f38519146cc.gif[/img] With all that done, [url=https://www.youtube.com/watch?v=AbSehcT19u0]I finally changed that light bulb[/url]. [h2]The collateral damage[/h2] I shot a few missiles while testing just because it was fun, and it reminded me that their effects needed to be adjusted for water too. Now that I had air and water explosions, I could use those instead. So I switched the effects, shot a missile into the water, but it didn't play the splash effect? Not only that, but upon closer inspection it didn't even touch the water. [img]https://clan.cloudflare.steamstatic.com/images//40742388/e651ff1b0aa64829d22216897c6492a6ad0f58d9.gif[/img] Turns out, working as intended. Missiles actually use a proximity fuze which is affected by terrain all the same as it is aircraft and vehicles. I also tested this with bombs, since I was curious what this looked like over land. It required a very long arming time to prevent the bomb from proximity fuzing on the plane instead. So long in fact, that the bomb was hitting the ground before it armed. Except, it was still exploding on impact even though the fuze hadn't armed yet. So I fixed this bug, and added handling for what happens if a weapon impacts something before being armed: dud munitions. This needed some appropriate effects, so I borrowed the collision effects I created for aircraft colliding into things. The end results speak for themselves! [img]https://clan.cloudflare.steamstatic.com/images//40742388/0d4eb259375eff8286acb2e895b6754a8a692004.gif[/img] Duds don't mean [i]no[/i] damage gets applied either. They still carry kinetic energy and both damage apply force to the things they hit, proportional to their mass and relative speed. [img]https://clan.cloudflare.steamstatic.com/images//40742388/69a945dcaad74cbc0cf486731100e44a2af249cc.gif[/img] Though, one thing was still bugging me about the air bursts. When they would explode over terrain, due to a lack of shadow, it wasn't clear that they didn't impact the ground. In fact, it was pretty misleading because it looks like it hit the ground, but the ground is actually a lot lower than you think. It could confuse the player into thinking they were higher than they actually were. In keeping with all the recent changes with engine splashes and terrain checks, if any weapon airbursts and its warhead is large enough, it'll also create a splash on the ground. [img]https://clan.cloudflare.steamstatic.com/images//40742388/0c7ceb9e50763af72b6eed6cf41105950fe3a960.gif[/img] [h2]Why don't you just..?[/h2] Oftentimes changing something will have knock on effects on various other aspects of the game or codebase, and those changes can potentially cascade further into other their own issues and so on. Many times these are predictable by somebody experienced with the codebase and can be scheduled around, but sometimes they aren't, and it can cause a snag of unknown time in the process. With experience you can learn to predict, plan for, and mitigate these kinds of problems. With regards to this water damage stuff, the only real surprise was fixing some old munitions bugs and improving on those features. The rest I had a pretty good idea of what it would involve, and why I had been putting this off for some time. It wasn't really a high priority yet, and it wasn't going to be a trivial change. Every time a feature is proposed [url=https://trello.com/b/1SODg7IQ/tiny-combat-arena-early-access-development]or planned[/url], I'm always doing the math for how much would this cost to implement. Not just the feature itself, which can sometimes be fairly simple (e.g. getting water to do damage to the aircraft took only a couple hours) but in order for a feature to be [i]truly[/i] implemented, in a way which meets and hopefully exceeds expectations, there will almost always be additional work and polish. [h2]Ghosts in the Night[/h2] If you made it this far, thank you for taking the time to read through what was honestly a pretty average (and thankfully fun) chain of events that not only led to fixing some long-overdue bugs, but also a couple cool new features that have given me ideas for future weapons, units, mechanics, and balance. I leave you with a cool WIP teaser image of work that's actually ahead of schedule! [img]https://clan.cloudflare.steamstatic.com/images//40742388/4f326b8e3c5f4a1c245d3868eb563125ec1160a9.png[/img]