Unreal Engine Posing a skeletal mesh & saving/loading poses at runtime

Velomous

Member
Jan 14, 2024
265
227
I discovered kinda by accident a quite good way to make it possible to pose a skeletal mesh, as well as less on accident how to save and load poses. This could potentially be useful for creator oriented game features.
View attachment 170824-044716.mp4

















View attachment 170824-044520_web.mp4

















Prerequisite: You gotta be able to click and drag physics objects (particularly skeletal mesh bones) in game, here's how you can do that.
Note: Your control a lot of the posing (making sure limbs don't bend the wrong way and such) so having good constraints is pretty important for this to work right.

First you gotta enable ragdoll, and collisions for the mesh which are required for ragdoll to work:
24-08-131.png
Then you have to put all the physics simulating bones to sleep on event tick: (This is a very bad way of doing it, what you should instead do is open the physics asset of your mesh, and then make an array with the names of every bone that the physics asset is using, and then using that array instead of the get all socket names below)
24-08-132.png

That's about it for making the mesh poseable, because of how rigid body sleeping works, all the relevant bodies will wake as soon as they get any sort of physics interaction, but because we keep putting them back to sleep on every frame it creates this situation where we can drag the mesh around and pose it freely.

Then we need to be able to save and load poses, otherwise what would be the point, right?

Here's how I did that. First, in the animbp I create a reference for the skeletal mesh.
24-08-125.png
Then I create this event to save the current pose as a snapshot, this could also be done from the blueprint instead of animbp but since we're only ever going to be able to use the pose snapshot from inside animbp anyways, I figured I might as well make it do the work of saving it too.
24-08-126.png
Then in the animgraph this is how I switch between the currently saved pose and the default execution path, this is just as an example of course there's very little practical use in doing it this particular way (this is just proof of concept stuff). Note that I also created a bool to use as a toggle.
24-08-128.png
Then in the blueprint side of things I call the snapshot pose event when I want to save the pose
24-08-130.png
Then to display the saved pose like in the clip up top I load it like this:
24-08-133.png
To explain what it's doing, it disables the ragdoll (I do this because when we are in ragdoll mode with all physics bodies sleeping animation/poses will not work properly. If you don't wanna disable the ragdoll then you'd have to disable the sleeping on event tick stuff instead.

And that's it!

Tip: You may also want to save the mesh's world rotation, a least on the X and Y axes and load that too when you load a pose, this'll ensure your pose won't load crooked like in my example clips.
 
Last edited:
May 19, 2022
161
105
oh shit you basically made captain hardcore's grab system nice. are you also using 5.4 features like modular control rig and motion matching?
 

Velomous

Member
Jan 14, 2024
265
227
oh shit you basically made captain hardcore's grab system nice. are you also using 5.4 features like modular control rig and motion matching?
Nah I didn't dive that deep, what you see in the tutorial is everything I'm using. I also have no idea who this captain hardcore is.

After stumbling on the sleep trick, it was just a matter of figuring out a way to set up the animbp to be able to save and load poses.

There's probably a lot that could be improved, and quite a bit of work to go from this to an animation timeline system, but it's a start.
 
Last edited: