Jump to content

How to obtain reference for BodyRagdoll


Recommended Posts

Posted

Hi,

I want to get instance of already present BodyRagdoll, for my skinned mesh object.
Skinned mesh is animated, it has RagDoll body with auto generated bones.

But instead of gettting it the reference, I got null

 

[Component(PropertyGuid = "3597362dbf0f08592cfef11903849cbb6624a161")]
public class AnimatorController : Component
{
  private BodyRagdoll myDoll = null;
  private ObjectMeshSkinned skinnedMesh = null;

  private void Init()
  {
    skinnedMesh = node as ObjectMeshSkinned;  // this is OK
    myDoll = node.GetComponent<BodyRagdoll>();   // this is NOT ok

    if (myDoll == null)    Unigine.Log.Error("Obtained BodyRagdoll is null!\n");
  }
}       

 

 

Posted

I am asking this, because I want to programatically stop framed animation and turn on the ragdoll, so character falls on the floor

Posted

Hello!

@kgregorThe issue is that the body ragdoll is not a component. It's a class that inherits from another class Body() https://developer.unigine.com/en/docs/2.17/api/library/physics/class.bodyragdoll?rlang=cs

So, instead of using this:

Quote

myDoll = node.GetComponent<BodyRagdoll>();   // this is NOT ok

You might try something like the following:

Quote

BodyRagdoll myBodyRagdoll = skinnedMesh.GetBody() as BodyRagdoll;

Thanks!

×
×
  • Create New...