Reset physics actors but not level?

I realize a similar question has been asked several times on these forums but not with the specific outcome that I am looking for.

What I want to do is create a “level state” reset that I can call on a key press that resets all physics actors back to their original location without having to load the level again. Is it possible to do this?

Essentially I want to be able to simulate physics on a ragdoll several times over without having to jump out of the game and back in or reloading the level. Its for an animation sequence that I’m filming in-engine.

Thanks!

It really depends on what else you are doing.

If you are not removing (destroying) any actors you could just save the original transform of the actors and use an “Event on destroyed” to spawn your actor at the same location again.

On your button press destroy all actors in your level and you’re good.

Otherwise you will have to manually do that by destroying all old actors and spawning in new once.

There is no finished solution from Unreal.

Thanks for the reply Erasio.
Ok. I’ll give that a try and let you know the results.

So I’m having a hard time figuring out how to set this up exactly. What I’ve got so far is this…

I was thinking I would be able to get all actors of class on the skeletal mesh that’s in the world and then spawn it again but it won’t let me connect the skeletal mesh that’s in the world to the actor class of the get all actors of class node.

If its just a skeletal mesh that I dragged into the scene and not a class on its own, how to I reference it to spawn it again?

I am not entirely sure if that’s possible. Since I’ve never been in such a situation I also don’t know a lot about it though.

Since the mesh is placed in the level it has to be an actor. Objects can’t be placed since they don’t have a transform and therefor no position. You could try simply casting your reference to actor and check if it’s successful. You have a reference from the level so it’s somewhat likely.

If this doesn’t fix it for you write again and I’ll take a look in engine if I can dig up anything :slight_smile:

Ok I got it working by taking a different approach. If anyone else wants to do something similar here’s my solution:

What I did was create a blueprint with my skeletal mesh actor inside it, that way it becomes a class and I can use Get all Actors of Class on it.

Inside the ragdoll blueprint, you need to of course add your skeletal mesh but with the mesh selected, scroll down the list to the collision area and be sure to specify a Collision Preset (I chose ragdoll) otherwise it won’t simulate physics when you tell it to (Thanks to Sean Flint). Next you need to place a target actor where you want your ragdoll to spawn.

Then inside the level blueprint, this is how I configured things:

With your target selected in the world, you can grab a reference to it and then have the engine spawn your bp_ragdoll at the transform of the target. Then when you want to “reset” the scene, you simply get all actors of class and for each - destroy actor.

If you wanted to do this with a destroy-able wall for example, you could use the same setup. To get your target into the exact correct position, place the actor itself in the world first (not the blueprint) and then once you’ve got it in the correct place, right click to the right of its Location in the details panel and you get the option to copy its values which you can then paste into the target’s Location and then repeat with the rotation.

Also, if you’re using an impulse to “fling” the ragdoll as I am, you need to set the Impulse Strength really high. I’m using 1500000.0 (though I also increased gravity in my project and scaled up the mesh to 2x its normal size). With default values, the ragdoll didn’t even move until I increased the Impulse Strength to +50K