Sunday, March 12, 2023

Rigid Body Animation Nodes

Random banter


Hello dear reader, long time no see.
While my SpaceStrategy project is on a halt ;) I'll take a liberty and post here some articles not related to the project specifically but to GameDev in general.

So, lately I've been polishing my Unreal Engine skills. This is a really great tool, may I say. BTW you can check some of the things I'm working on my YouTube channel. But my lightning-fast improvement stumbled upon a small stone on the way to the absolute UE-mastery summit. I would like to share this small challenge I encountered and write about a solution for it.

About Procedural Animation


There exists this amazing trend in modern GameDev called Procedural Animation. It encompasses lots of techniques like IK, Rigs, Layering, Blending etc. But today I'll say a few words about this particular technique when animation is created based on a physical simulation of collisions.

Say, you make a knight character and want to make a scabbard on his belt. And, for sure, it would be nice if the scabbard shakes and swings realistically when the character moves around doing various exercises like running, fighting, or dying... ahem. 

Of course you can add a few bones and simply make this scabbard swinging a part of all the knight's animations... You just need to keep in mind all premade animations, animation blends, procedural animations, modified animations... you see my point already, aren't you? Or you can make it so that the game's physical engine calculates the scabbard swinging dynamically for any kind of situation.

Rigid Body Animation Nodes


This particular technique in UE is called "Rigid Body Animation Nodes" or RBAN. I wouldn't dive into too minute details, but I recommend to check out the Epic Game's official tutorial on this topic

The main idea behind this technique is that the scabbard gets its own bone, but instead of animating it by hand, we assign collision shapes to the scabbard bone and all neighboring bones and add a constraint between them, so that the UE itself calculates the motion of the scabbard given its environment.




The tutorial I mentioned is superb and everything is crystal clear... except that it didn't work for me. My scabbard collision body stubbornly continued to ignore other collision bodies. I spent a whole day digging and educating on this topic, before I found the reason. The tutorial was lacking one crucial piece of information: one has to enable collisions between bodies by hand, otherwise they won't collide!


Lessons learned


In my last blog post I wrote that if you follow a tutorial and something doesn't work then chances are 90% that you didn't follow the instructions precisely. This particular case falls into the remaining 10%: tutorial didn't mention this detail. But the next lesson I would take out of this situation is the following:

"Before working on advanced tutorials, first work through basic tutorials on the topic because advanced ones are very likely to suppose that the reader already knows the basics."


Have a happy GameDev'ing evening.
Best regards.