Another week another devlog! This week has so far been a bit rough for myself as I have been struggling with the subject at hand, Inverse Kinematics(IK)!
This and last week I have been getting into IK which stands for Inverse Kinematics. IK in this case refers to the calculating of skeleton joint parameters(location, rotation) needed for placing a joint in the right place depending on the skeleton’s surroundings(for example a hand and arm). That said, the mathematics behind IK can get very confusing. Luckily, using Unreal Engine, we don’t really have to care about what is going on inside the engine — however, some difficulties remained. The IK built in to unreal engine is very simple, which is very good thing for most use cases as the threshold for who can use it becomes lower, in my case however this lead me down a rabbit hole.
Simon “Vito” Gustavsson
Using IK in unreal is as said very simple as you only really have to give the location where you want the joint to target and which other joints should also follow. In this case it would be where I would want the hand to target a ladder step and all the joints leading to it from the shoulder, which is simple enough. This is where the problem arose: there was no interpolation between the positions, so whenever I wanted the hand to switch to the next rung, it just teleported there.
So this lead to me having to come up with a solution for the interpolation and I of course googled the problem, but I couldn’t really find a solution online so my brain was going to have to work a bit harder. After some consideration I came up with that what I wanted to do was go from the old location to the new location, and I knew there existed blend nodes for general animations, so my first test came out to try to blend between old locations that had been used and interpolate between the new location. Here I used a node called blend node by bool which in hindsight was the most foolish idea I have ever had, however this function had a blend time which made it enticing for me to try out. This solution I did not like as there were many variables that needed blending and the animation code became too big and unreadable.
However, it also had a grand flaw: while the blending worked brilliantly, it would always lag behind. This is because when using Blend Node by Bool it interpolates between the position given at the start of the blend. During this time, the solver does not update the target position, causing it to lag behind by however long the blend time is. This made me also understand why unreal does not have a built-in blend for IK. This lead me to try out all different kinds of blending between animations and I found one I really liked that was about what I was imagining, just a simple interpolation with an alpha variable that seemed to work fine. This is also where I found out you could save previous poses from you character(which I should have realized earlier) so I did not have to use so many variables for using the damned bool node which also fixed my problem with blend times.
All said and done I still do not like looking at how small the solution became in the end, it makes me feel stupid for making such a complex solution to begin with. Nonetheless I still have some minor tweaks to figure out, like right now it jitters a bit too much while climbing and also some IK for going against walls and for the legs. but now I am going to take a little break from doing this and test out some new smart objects for NPCs in unreal(maybe a topic for another devlog :P)
That is it for this week, hope y’all are doing well! Au Revoir!
Remember to wear your helmets and to follow orders and…
Return food at restaurants and then dig through the trash to get it for free!~ The Gumlin