My enemies turn into ragdolls after dying. After slaying more and more of them, battlefield is scattered with ragdoll bodies that are constantly simulating physics. I guess it’s bad for performance?
I would like to optimize it by disabling physics simulation after like ~10 seconds from death. But when I simply call “Set Simulate Physics” function on a skeletal mesh, it goes back into T-Pose.
Is it possible to ‘freeze’ current ragdoll pose and prevent it from simulating physics?
Any clues? I saw something like this in a few games, enemy ragdolls were active for ~10 seconds and then their physics simulation turned off.
But in UE, I still can’t figure out how to keep ragdolls in current pose, instead of reverting them back to T-Pose.
I think there is a node called PutAllRigidBodiesToSleep. I think that is what I’m using to freeze the ragdoll. I also have to turn off certain collisions so other players can’t start kicking the frozen ragdoll, although it is pretty hilarious to see.
I would put more details into this but I’m at work. If you haven’t figured it out by the time I get home, I’ll post the nodes I use for the death sequence.
I don’t remember 100%, but probably inside enemy class, in a custom ‘FreezeRagdoll’ function. So the ‘Mesh’ node is your enemy skeletal mesh. Then every time you need to freeze a ragdoll on an enemy, you call the ‘FreezeRagdoll’ function on it and it works.
Sorry for the necro, but I tried out this technique and it seems to work pretty well, except that when the meshes get swapped out I start seeing this weird blur on the bodies. It looks like it might be motion blur, but I’m not positive. Has anyone seen this or have any ideas what could be causing it / how to fix it?
so I have a workaround … instead of creating a poseable mesh I do this in my enemy BP … save pose snapshot > set bool variable(freeze) > set all bodies simulate physics(off). Then in my animation BP just pass in the freeze bloolean and use that to change my state. Inside the state just use a pose snapshot with the same name as set in my enemy BP. Not sure how efficient but seems to work fine.
So this is the solution I went with. It’s just a single line of code, just add a
and it freezes the ragdoll.
But this is just so easy and the other solutions posted after this in this thread are so overly-complicated that I’m thinking maybe putting them to sleep isn’t enough? I assume when you put them to sleep they completely stop all physics queries so it has zero performance impact from physics, so it would be just as good for performance as the other solutions here, right? Or am I missing something?
In 2020 you are probably better off creating a Dead animation state, taking a snapshot pose of the mesh when it’s finished bouncing around (which should be implemented manually during the “ragdoll” state), and putting the mesh in that state.
I’m not 100% done with my system or I’d share some more details about it, but suffice it to say, that you can use physical animations instead of simulating physics without any control of the rigidness of the different bodies.
Another thing to note, to prevent the meshes from spazzing out I ended up scaling the tensor from the extremities inwards with X values of 5,4,3,2.
You and anyone else can mostly follow the live training for it.https://youtube.com/watch?v=N1tDjbFXeOo
There are a few gotchas that you may come across, but anything is better then leaving the actor in a ragdoll state, performance wise…
I also had a issue that after the dead anim the skeleton goes back in Tpose…I solved like this:
get last frame of your dead animation, create a new animation from it with just 1 frame (it will have the body dead on floor), then play that anim after the dead animation and tag Loop to True. In this way the skeleton will die, play the dead animation, then if needed put a delay N sec (N=dead anim length) and when done, play the new anim in a loop.
I tried the first method, with named snapshot and while it works, there is a massive jolt happens to the mesh when taking pose snapshot So it’s basically unusable due to that. Any idea why and how to eliminate that jolt ?
I haven’t tried second method because it’s not going through fast path.