The Making of Whale
One of the things I enjoyed the most while playing 《Drifting》 is to watch the protagonist running and dashing between walls and ceilings with graceful movement and fluid animation – whilst savoring that wonderful moment, I often asked myself: wouldn’t it be an even more memorable experience if the protagonist could run and dash on moveable, animated characters? I wrote down this idea on google doc and continue with my development. Several months later, as I was building the ocean courtyard level, I realized the layout of the level could be a perfect place to put that thought into action – making a giant whale that allows players to hook onto it and perform all kinds of neat tricks on it.
(this beautiful ocean creature is a humpback whale. According to wikipedia,
males are able to sing a complex song lasting 10~20 minutes)
The idea of wall-running on an animated character is easier said than done. As I undergo several changes to my code to allow the protagonist to run smoothly on an animated and moveable actor, all kinds of weird bugs and technical obstacles arise. Among the many issues, two of them gave me a particularly hard time dealing with: to create a good enough collision approximation for an animated character; and solve the problem of relative motion between the protagonist and the whale.
Generate Collision Approximation
Upon importing the whale skeletalmesh into UE4, the first issue that rises up is the need to generate a good enough approximation for the skeletalmesh, which in turn, allows my wall-run system to perform line trace on it. The UE4 default support for character collision is a simple capsule-shaped geometry – way too simple to handle this delicate task. I then proceed to use UE4 physic editor to generate physic body for the skeletalmesh, where each body inherits the transform of the parented bone – the result isn’t bad for most of the time, however, since the physic bodies are essentially small meshes attach together, there are unavoidable gaps between them, causing the wall-run system to produce a slight hiccup while players moving from one body to another. The issue is even worse if the parent bone is animated dramatically, which could lead to the protagonist exit wall-running unexpectedly.
(noticed, at the “collision geometry” section, I chose “single convex hull” instead of “sphere” or “cylinder” – which produce a terrible approximation for the whale mesh)
After several trials and errors, I noticed there is an option for generating physic body which could either be “dominant weight” or “any weight”. The default is “dominant”, where bodies are limited to their highest bone weight; by choosing “any” the generated bodies extend further beyond the highest skin weight area and cover a large proportion of the mesh – essentially eliminates the necessary body count from 13 to 7. I then hand-picked the 7 bones that are animated more dramatically and generate their respected bodies, resulting in these bodies covered a large area including areas where bones do not have much movement in its animation data, which in turn, reduces the impact of the gap between each body.
(before selecting the “any weight” option, the most prominent gaps happened around the whale’s dorsal fin where bones are animated most dramatically; after the size adjustment, the problematic part consist only 1 large mesh and thus no gaps are present)
The downside of this approach, is the larger bodies are less accurate approximation compare to smaller bodies and thus, could create a visual discrepancy in certain areas. Nonetheless, I think the final result is a “good enough” approximation with significantly fewer hiccups for my wall-running system. Overall, an acceptable tradeoff in my opinion.
The Issue of Relative Motion
A distinctive difference between wall-running on static walls versus moveable whale is relative motion – a non-existent issue in the former. Real-world physics aside, in terms of gameplay design, the matter is whether the player should attach to the whale (enable relative motion) or not (absolute motion) while wall-running on it. I’ve done some thought experiments on this matter and decided to adopt absolute instead of relative motion for wall-running on the whale. The preference for absolute instead of relative is due solely from a game design aspect.
In 《Drifting》 part of the challenges while wall-running is to adjust movement height and camera angle (adhere to the underlying geometry) in order to maintain wall-running status, it’s a skill that the game requires the player to learn and eventually master it and feel a sense of accomplishment and fun in the process. By attaching the player character to the whale, renders the aforementioned challenge obsolete, since, all movements and camera turns are now relative to the underlying geometry (the whale), there is no point for players to observe the geometry layout and adjust the height and camera angle accordingly. Attaching the player character to the whale changes a dynamic interaction into a static gameplay experience.
(the thick arrow indicate the speed of the whale; the thin arrow indicate the speed of player; as long as the speed are constant it is easy to maintain the player’s position while wall-running in absolute motion; whereas under relative motion, the player is likely to reach the end of the whale and stop wall-running prematurely)
Another gameplay-related reason in favor of absolute motion is to maintain the players’ location even if they are running forward. Since the game uses the whale as a temporary travel mechanic, players are expected to leave the whale upon arrival at their destination. Adopting relative motion often causes players to reach the whale’s head (the end of the wall-run geometry) before arrival, in which players either fall into the ocean or hook onto other parts of the whale – both are not a particularly pleasant experience. By using absolute motion, as long as the whale is travel at a constant speed, it is relatively easy to synchronize the speed of the player and the speed of the whale so that players are at (roughly) the same location while wall-running on a moving whale.
Here is a short video clip, demonstrating this beautiful creature in action:
(one small issue I couldn’t figure out a solution just yet, is how to inform players to hook onto the “right side” of the whale; since, without prior knowledge, nothing prevents the player to hook onto the “wrong side” of the whale and forced to switch side when the whale reaches its destination)
I hope you enjoy this week’s update, feel free to leave a comment or follow this project!
Have a wonderful and relaxing weekend! ヽ（・∀・）ノ