In the world of 《Drifting》, most enemies are either human-like or mechanical creatures, which means the enemy either requires a bipedal rig or no rig at all. The idea of an organic tentacle poses an interesting challenge in terms of animating its behavior and simultaneously directing part of its body to a specified location via scripting. In this week's update, I like to share the solution I've made to overcome these challenges and the resulting outcome.
After delving into the problem, I found out the biggest challenge lies in its attack behavior. To perform a successful attack, the head-bone of the tentacle needs to reach to the precise location of where the player's at, which means the attack location and rotation cannot be pre-determined. Using IK to direct head-bone solves the problem, however, that also means all of the spine-bones above the head-bone need to be in the IK chain, this, in turn, renders animating the spine-bones obsolete. Using FABRIK in UE4, there is an alpha pin to tweak the strength of IK, but after some testing, lower alpha value results in (not surprisingly) less accuracy for IK.
Approaching this problem by using IK alone, essentially results in a tradeoff between less IK accuracy or less animated spine-bones, both cases are not a desirable outcome for what I am aiming for.
After some thought experiments, I came up with an idea that may have a chance to get me closer to what I want.
(This setup has the head-bone 100 percent IK-driven and spine-bones 100 percent physics-driven.)
Instead of using animation to drive the spines, I set up all the spine-bones to be physically driven and the head-bone remain 100 percent IK-driven. The idea is to let the IK head motion "direct" the spine-bones via the engine's physic system. After tweaking some parameters the result is quite close to what I envisioned in the first place:
(Notice the slight twist of the spines when tentacle finishes its attack,
these are all physically driven, not animated.)
A disadvantage for this approach is that, since the attack motion happened in an instant, sometimes the physic spines will have a hard time to catch up with head-bone IK, causing the head to thrust inside the spine temporarily. That being said, I am pretty satisfied with the end result and it's fascinating to see physic driven animation could be on par with key-framed animation in today's engine.
Here is a short video demonstrating the combat between the player and the tentacle:
(The tentacle attacks only when the player gets near the ocean surface. It has a very fast attack speed yet a very obvious weak point, overall, it is a minor but annoying enemy in the game.)
And that wraps up this week's update. I hope you enjoy reading my article, feel free to leave a comment or like!
Have a relaxing weekend! ヽ(‘ ∇‘ )ノ