x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How would my pawn go Ragdoll and then back to animations?

Is there a way to make a pawn go ragdoll, fall to the floor for a few seconds, and then play an animation of the pawn getting back up and continuing to work normally?

Product Version: Not Selected
Tags:
more ▼

asked Apr 19 '14 at 07:43 AM in Blueprint Scripting

avatar image

ClaverFlav
357 29 148 200

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

To turn to ragdoll, you just have to enable physics simulation.

// enable physics for all default bodies. // if you have fixed bodies, you'll have to call SetAllBodiesSimulate to unfix all of them

 SkeletalMeshComponent::SetSimulatePhysics(true) 

// now wake up all rigid bodies.

 SkeletalMeshComponent::WakeAllRigidBodies();

But also you have to disable Pawn's movement/inputs so that they can't move their mesh.

If you'd like to go back, you'll have to do this in reverse.

You'd like to put sleep on rigid body, so it doesn't move anymore.

 SkeletalMeshComponent::PutAllRigidBodiesToSleep()

But also you'd like to disable Simulate, but enable blend so that you don't simulate anymore, but you'd like to blend from physics position over time.

 SkeletalMeshComponent::SetSimulatePhysics(false) 

You can call this function to set how much weight you'd like.

 SkeletalMeshComponent::SetAllBodiesPhysicsBlendWeight

Ideally over time, you'd like physics weight to be 1->0 over duration of the time.

You can do all this in blueprint.

Thanks,

--Lina,

more ▼

answered Apr 28 '14 at 10:03 PM

avatar image

nikolobin STAFF
705 14 12 33

avatar image ClaverFlav May 01 '14 at 05:33 AM

Wow thanks... im guessing these are all the same names for blueprint side right??

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Thank you very much, Lina! I managed to do it with your instructions. Here's my approach through Blueprint.

Example 1: https://dl.dropboxusercontent.com/u/73643078/examples/falling_down.png

So I set out to make it so that if the player holds F he will turn into a ragdoll and if the player releases the key, the character will stand up with physics blending. For starters, I disabled input for the Player Controller (you'd probably want to actually grab the Character's Controller rather than 'Player 0' like I did here) then I turned on physics for the Capsule Component because I was lazy and didn't want to find a way of disabling it without the character falling through the ground. If I were doing this for reals I'd probably scale down the capsule component while the player is a ragdoll or something along those lines so that it doesn't inhibit the normal physics of the ragdoll.

Note: Your Capsule Component must be set to a 'Custom' physics option. To do this, set the capsule component's collision preset to 'Ragdoll' then change it to 'Custom'. From there, you're going to want to check the "Ignore PhysicsBody" check box so that the capsule doesn't infinitely collide with the ragdolled mesh or fall through the floor.

Note 2: The blue man skeletal mesh doesn't come with a physics asset. You must right click the skeletal mesh in the content browser and generate one. You must also set the collision preset of the mesh component to 'Ragdoll' in the character blueprint.

Next, instead of simulating physics directly like Lina suggested, I chose to "Set All Bodies Below to Simulate Physics" for all bones below bone index 1. (the pelvis) This way, the root stays attached to the Capsule Component and the two do not become detached. (which otherwise ends up with very strange results) Now if you were to test this out, when you press F your character will turn into a ragdoll. Make sure you jump forward or something first, as the Capsule Component can stand on it's own and your character will kinda just start dangling in mid-air otherwise. This is why I think it would probably be a good idea to scale down the Capsule Component when the character actually ragdollizes.

Next was getting the character to stand back up with blending.

Example 2: https://dl.dropboxusercontent.com/u/73643078/examples/standing_up.png

Upon releasing the F key, physics are no longer simulated on the Capsule Component, Move Input is re-enabled, and Actor rotation is set to (0,0,0) to undo any rolling the Capsule probably did. You can ignore the "Set Enable Physics Blending" node, as well as the next "Set All Bodies Below Simulate Physics" nodes, as they are actually unnecessary. It's important to note that physics must still be simulated in order for physics blending to work, which is probably the only problem in Lina's tutorial (This could just be a Blueprint thing though), so make sure that you don't "Set All Bodies Below Simulate Physics" to false until you're done blending the mesh back to 0.0, which we're about to do.

By this point your character will stand up again, but he will still dangle in mid-air and it generally looks hilarious as you run around like this.

Finally you're going to "Set All Bodies Below Physics Blend Weight" to a custom float variable with a default value of 1.0. As Lina mentioned, you're going to want to gradient this value down to 0.0 so that the character slowly goes back to his normal animations. You can do this by setting up a timer to subtract 0.1 from the blend weight every certain number of second or any other way you'd have a value change over time. To make it a bit more polished you could have a getting up animation start to play right before you start doing the blending, and you'd get an Unreal 3 feign death type look from that.

And that's my pretty rough way of getting this to work with Blueprint! I'm sure there are several areas that can be improved, such as what to do with that clunky Capsule Component, but I bet you can figure out where to improve on it on your own. Like I said, my first guess would be to shrink the capsule component down while they're a ragdoll and scale it back up when they stand, but that could have problems all its own.

To further complicate things, none of the ragdolling is replicated, so that's something else we still gotta figure out.

Good luck!

more ▼

answered May 02 '14 at 12:38 AM

avatar image

TwinSeek
116 3 8 14

avatar image Tylru Oct 20 '14 at 12:23 AM

I've followed this setup exactly as written (thank you for that), however when entering ragdoll, the ragdoll seemingly gets stuck in it's midsection and hangs there in mid-air (as you described would happen when exiting the ragdoll).

Haven't been able to figure this out at all. Wondering whether there is any fix. I feel like it's something to do with the "Get Bone Name" index being "1", but I'm not sure. (Using AnimStarterPack skeletal mesh, btw).

avatar image Tylru Oct 20 '14 at 12:26 AM

The reason I think it's the "Get Bone Name" index, is that whenever I change that to the actual bone name (Root), the ragdoll falls correctly, however when exiting the ragdoll, my character starts mid-way into the floor.

avatar image DmBd_Kermit Jun 18 '17 at 09:42 PM

Despite having the same blueprint, when going into ragdoll mode, the player still falls through the world. I have double checked everything, I did everything the same way.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Thank you so much for the feedback. This is very helpful.

I expected it's going to have some hurdles because this hasn't been tested well but I'm glad to hear you managed to make it work.

Note: Your Capsule Component must be set to a 'Custom' physics option.

Could you not just disable collision of capsule when you go ragdoll? And enable collision again when you're out of ragdoll?

Next, instead of simulating physics directly like Lina suggested, I chose to "Set All Bodies Below to Simulate Physics" for all bones below bone index 1. (the pelvis)

I think this was smart move. I think the key is though you'd like to make sure root doesn't have weight and on the ground. Like other mesh often imported root as pelvis or hip.

It's important to note that physics must still be simulated in order for physics blending to work, which is probably the only problem in Lina's tutorial

When I get to this, I'll look into this again. My intention is not simulate, but it seems there is code blocking blending with physics when not simulating. Thanks for the tip.

To further complicate things, none of the ragdolling is replicated, so that's something else we still gotta figure out.

We have a rough plan to work on this, not necessarily just ragdoll, but physics object replication. Ideally it would be great if you don't have to, so it would look seamless in every machine although they all see different simulation.

Thanks,

--Lina,

more ▼

answered May 06 '14 at 06:43 PM

avatar image

nikolobin STAFF
705 14 12 33

avatar image TwinSeek May 13 '14 at 08:31 AM

Yeah,I tried disabling the capsule component's physics, but since it's the root of the object the ragdoll's root bone will keep floating wherever the capsule's physics were disabled, or in the case that you enable physics on the ragdoll's root bone, it will become detached and go off on its own while the camera stays with the frozen capsule component.

I figured the easiest way out would just to enable physics on the capsule component too, and that way when the character needed to get back up it was simply a matter of rotating the capsule component back to the correct orientation and blending the ragdoll.

Anyways, that was just what I came up with from messing around with it for a couple hours. There's definitely something else we could probably do with the capsule component that would have a slightly cleaner result.

Also that sounds great! A simpler way of adding in the replication in this type of situation would be awesome. Thanks for all your help!

avatar image SVAD Jun 18 '14 at 06:07 AM

Working on implementing this, here is a minor detail that will help. You need to set the collision preset for your skelletal mesh to 'ragdoll' or it will fall through the floor.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question