We use a combination of custom shaders, VFX and audio cues to achieve the desired effect.
We wanted to make landings after falling from a great height feel deadly yet satisfying.
The first thing we did was add a bit of camera shake.
Then some over-the-top VFX.
And finally an impactful audio cue to seal the deal.
These basic effects are nice, but they still weren't satisfying enough. We wanted the player's actions to make a visible impact on the world, so we realised that the environment itself needs to properly react to the crash landings. What we needed was a shockwave that ripples through the tiles, to really emphasize the almost superhuman quality of the protagonist, much like how its done in the movies.
All objects in the world that are affected by shockwaves are assigned the Shockwaveable Monobehaviour component. Obviously all of the modular tiles that make up the terrain contain this component, but so do certain dynamic objects such as rigidbody crates and even enemy NPCs.
At the point of impact, we use a Physics.OverlapSphere() call to determine which Shockwaveable objects within a certain radius are affected.
For each Shockwaveable object, the normalized distance is calculated to the origin (the player's feet).
This distance value is used to modify the animation of the shockwave, basically the closer it is to the origin, the more intense the animation.
The ActivateShockwave() function is then called on each affected Shockwaveable object, passing in various parameters :-
Once the activate function is called, the animation is then applied over the duration of the shockwave via LateUpdate.
To do this, we simply feed in the current frame time (taking into account the specified delay and duration) to the animation curve, and then assign the resulting value to the renderer's MaterialPropertyBlock on every frame. The rest is then handled in the shader.
Curve A: Distance attenuation curve for the shockwave strength and delay time
Curve B: Animation of the shockwave over time (decaying wobble effect)
Applying the tint color in the shader is very easy, we simply use an additive color and multiplier on the albedo.
To start off, we used a bright green color without vertex offsets to quickly and easily test the shockwave animation curves.
Because we're using an overlap sphere, the effect also works vertically, for example across these steps.
The vertex displacement on the shader side is also very simple as the only thing we have to do is add the supplied _SHOCKWAVE_Y_OFFSET.
All of the actual animation timings are handled on the script side with the curves as explained above in Step #2.
We do need to ensure that we convert the vertex to world space first (and then back again afterwards) so that the offsets are consistent across all of our tile models.
The subtle tint color is reincorporated back into the shockwave effect to improve clarity.
We chose to match the player colors to keep the palette consistent.
Some Mesh Distortion was added to the original VFX to emphasize the shockwave power even more.
Any nearby rigidbody objects get an explosive force applied to them at the point of impact, increasing the feeling of physicality.
Finally, we also deal damage to any enemies we land on. The crash shockwave now becomes a legitimate melee weapon.
Recompile is an atmospheric action exploration game, combining 3D precision platforming, intense combat and environmental hacking mechanics.
Found out more about the game's development on Twitter. Thank you for reading!