Let the Prototyping Begin
We are currently hard at work prototyping another batch of levels for Just In Time Incorporated. One idea we’ve had in the back of our minds for a while now is a scenario where the player needs to save people jumping out of a fiery building. As an idea, this level inhabits that sweet spot where the entire concept hits every design pillar for a game in the action-puzzler-bullet-time-insurance-agent genre.
After a few hours in Unity and many ProBuilder primitives later, the level was roughed out:
Imagination Meets Reality
The goal for the player is simple — have them place a bouncy pad under the falling person and voila they bounce off a few times and are saved! All that is needed is to put a really bouncy material on the physics colliders of the pad and things will work… right?
Yawn. In slow motion the bounce is even more boring if you can believe it.
Ironically one cause for the underwhelming result is what makes ragdolls so fun in the first place — their floppiness!
Each of our characters has a physically simulated ragdoll composed of 16 rigid bodies and all their connected joints. In a normal game it would be overkill to have such a detailed ragdoll. In Just In Time Incorporated the player constantly interacts with characters in slow motion and the extra fidelity really cranks up the fun factor. Unfortunately when the ragdoll hits the bouncy pad the flexible joints bend and end up absorbing much of the force that would otherwise cause a more respectable bounce.
Reality Meets Physics Hacks
The other root issue with the boring bounce is that physically speaking the bounce pad is an impossibly solid object without any ability to compress and store energy (thank you rigid body physics). One potential hack might be to scale the colliders on the bouncy pad down and then back up to simulate the compression of a soft body. If experience is any guide this is a one way ticket to buggy-physics land with all its interpenetrating object fun!
Thus it was time to whip out the default tool of any Unity physics hacker: AddForce!
It took more than a few hours to arrive at something that looked good and worked well in slow motion. All of the following hacks had to be layered together into a final Frankensteinian coroutine:
- Magic number your way to a force value that feels good at an arbitrary collision velocity reference point. That poor jumper character had to die at least 100 times to find out that at -10 m/s a force value of 24 felt right. R.I.P.
- Scale the force applied if we are in slow motion.
- Scale the force applied to diminish over an arbitrary time (0.4s felt good).
- Scale the force based on the collision velocity projected onto the local up vector of the pad. Without the projection, a sideways moving character will have a seemingly large velocity magnitude even if they are barely falling onto the bouncy pad.
- So the player can somewhat control the direction of the bounce, calculate a direction from the collision point to the center of the pad and then average it into the collision normal.
- In addition to adding force to the body part that hit the pad, add an impulse to its parent body part as well (e.g. foot hits, add force on leg too). Using an impulse adds a nice “oomph” to the bounce response.
With all the time spent trying to hack together a satisfying bounce, there was always the worry that the level itself might just not be fun. Luckily placing pads to make people bounce and ragdoll through the air is very, very fun. Phew.