kgregor Posted October 31, 2023 Share Posted October 31, 2023 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
kgregor Posted October 31, 2023 Author Share Posted October 31, 2023 I am asking this, because I want to programatically stop framed animation and turn on the ragdoll, so character falls on the floor Link to comment
bmyagkov Posted November 1, 2023 Share Posted November 1, 2023 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
Recommended Posts