- 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
First you gotta enable ragdoll, and collisions for the mesh which are required for ragdoll to work:
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)
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.
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.
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.
Then in the blueprint side of things I call the snapshot pose event when I want to save the pose
Then to display the saved pose like in the clip up top I load it like this:
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.
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
You must be registered to see the links
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:
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)
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.
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.
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.
Then in the blueprint side of things I call the snapshot pose event when I want to save the pose
Then to display the saved pose like in the clip up top I load it like this:
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: