Jump to content

How to obtain reference for BodyRagdoll


Recommended Posts

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");
  }
}       

 

 

Link to comment

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!

Link to comment
×
×
  • Create New...