Animations And Rigidbodies - Crossfade from rigid body position to animation.

So I have a rigid body character setup, when he falls to the floor for a few seconds, the rigid body and colliders in all components are turned off:

// Disable Colliders
	for( var c : Collider in theColliders){
		c.enabled = false;
	}
   	
   	// Disable Rigidbodies
   	for( var r : Rigidbody in theComponents){
   		r.useGravity = false;
   	}

but then I want to crossfade into an animation of him getting back up to his feet…

// Now get back up
animation.CrossFade("Getting Up From Front Static");

What happens is the character moves back to the original location of the scene and plays the animation without crossfading at all.

Am I missing something here? Any help would be greatly appreciated!

Thanks!

I think you can only use animation.CrossFade() between two animations. A ragdoll is no longer using animations and is driven by physics, so you’d have to script your own way of crossfading from physics to animations. You’d have to somehow play the animation and set the middle positions over time in LateUpdate() for each bone…

maybe another way would be to create a “one-frame-on-the-ground-as-a-ragdoll-animation/pose” via scripting at runtime and then crossfade from that one, but not sure if that would work.

either way, it’s complicated :stuck_out_tongue:

Argh I just wasted loads of time trying to answer this, because I was sure that just the other day I read about someone making a script that would record the final rag doll position into an animation clip, so that it is then easy to crossfade between this and the animation you want. But can I find any trace of this now that I look? No, so I don’t know where I was looking or if I was dreaming, how very frustrating!

I’ve been meaning to have a look at the Advanced Ragdoll Creator thats available on the asset store, it sounds like this contains such a feature but I will check and let you know.

OK just purchased it and Advanced Ragdoll Creator on the asset store does indeed do this. In fact thats about all it does, but I found it handy, its a question of time vs money really.

Thanks for the feedback guys.

Elbows, thanks for the suggestion, I bought the plugin and tested it, but it didn’t work with my setup. The animations blended (Sometimes), but I’m still having problems with the position offset.

At the moment, I’m building a custom controller to manually animate each part of the character to simulate a getting up animation. It’s painful at the moment, but I think I can just about get that to work … If anyone comes up with a cleaner solution, would love to check it out.

Thanks!

Sorry that didn’t work out for you, Id be more inclined to explore the details of the position offset problem than try a different and tedious approach, but talking about this stuff in detail isn’t always easy.

By the way for future reference if someone else finds this thread in future, I finally found the other script that records current position into animation clip, the one I wasted loads of time looking for the other day. Turns out I couldn’t find it here because its a PlayMaker script! Add Animation Clip (using current pose)