Help with Set RB Activation State

Hi, trying to disable/enable rigid bodies in Ragdoll example file,
I used the Array loop logic node to run through objects to set RB Activation State to inactive,
the result is that the rag-doll freezes and stops reacting as I wanted but whole player halts,too, debug message says “Trace: TypeError: Cannot read property ‘setActivationState’ of null”
Is my logic node setting wrong or Armory just can’t get/set RB state for now?

The goal is to disable/enable a animated character to be a rag doll when it dies.
Blender 2.89 LTS, Armory 22.01

Any help please, thanks in advance!

Hi Olsen,

I had the same issue with the “Set RB activation state” node and I used the “Remove RB” and the “Add rigid body” nodes instead.
It works in my case, perhaps it will be a solution for you.

Best regards.

1 Like

There are 2 issues I see form your node setup.

  1. You did not connect the Value output from the Array Loop Node to the RB input in the Set RB Activation State Node. Please make this connection first.

  2. The parent object “Ragdoll” may contain child objects which are not Rigid Bodies. For example Empty objects and other Mesh objects. These objects are not Rigid Bodies, so when you loop through all the child objects, the non-Rigid Body objects cause errors.

To solve this, you could add all the rigid body objects of the RagDoll (Only rigid bodies, not rigid body constraints) to a separate collection. Then, loop through this collection objects and set the activation state.

Let me know if this works.

Best,
QC


Thanks to @bxn and @QuantumCoderQC, appreciate your swift reply!

@bxn ,I tried using “Remove RB” instead of “Set RB activation state” and it freezes,too, looks like I get bad luck this time.

@QuantumCoderQC, I renamed all empty objects and moved them to another collection and it did solved the error messages, however the thing I don’t get is that “Set RB Activation State” node won’t work this time, even I tried to simply disable single head object to hang or release Ragdoll.
By the way,It won’t work if you try to simply filter out child with collection name , because you can only get certain child with specific name of parent, not for collection name.

I guess there might be some bugs in RB related nodes,
I’ll duplicate those steps over again see if I miss something.

Thank you guys again!

2 Likes

Hi,

“Set Activation State” is the wrong node for this job. Please have a look at how it can be done here. Use “Space” to freeze and un-freeze the rag doll

physics_ragdoll.blend (1.8 MB)

2 Likes

Appreciate your enthusiastic help, @QuantumCoderQC,
With your hint now that I can realize the meaning of value output of a node can use as a object source that without assigning child via “get child” node, I honestly have trouble to lookup or understand this subtle usage in the manual, that need some more efforts from the team someday, that will be a huge help!
I admire your solution,it’s a none-intuitive way and it works to pause the rigid bodies, what if I need to animate the armature further, will the bone-parent relation hinder the action control? Would it be better to disable the RB property?

Tons of thank to @QuantumCoderQC, this helps a lot to let me get into this interesting subject!

1 Like

Great, so it somewhat works… :slightly_smiling_face:

Right, so switching from animation to ragdoll and back is not something I have done as yet. It is not trivial, but I have an approach in mind that might help us do this.

But before we proceed, one important thing to keep in mind: Either the Rigid body controls the armature. Or the armature controls the rigid bodies. Both cannot happen at the same time.

So, lets first go from animation to RigidBody. The idea is this:

  1. We remove all the bone “Child Of” constraints to the rigid bodies before the export. We will separately control both the rigid body and the armature.

  2. with on init, “disable” all the rigid bodies as I showed in the example above by setting the velocities and the factors to zeros.

  3. Start the armature animation.

  4. At every frame, copy all the bone transform (Locations and rotations) to the corresponding rigid body. This way, the rigid body even if its de-activated, will follow the animations. This can be done with “get bone transform” and “set object transform” nodes.

  5. When key “space” pressed, all the rigid bodies must be activated (as in my example above). The animation must be stopped or set to idle.

  6. On update, copy the rigid body transforms to the bone transforms. So now, the rigid bodies control the animation system. This can be done by using “Get object transform” and “Bone FK” nodes.

What do you think?

Sounds trivial to me, I had just tried to set rotation of one of the rigid body (head) copying from a head bone rotation in another animated character, how ever I didn’t set the “child of” constrain off at that time, the result is that I can’t copy the rotation from a animated bone, but I can rotate the “head” rigid body in that kind of status.
I’ll try copying transform from bones next time, I’m always confused of bone matrix convert to object matrix, they often mess up when editing, not sure if those matrix match to each other.
Ragdoll seems won’t work if the armature contains animation data as I tried,
looks like the only approach to this goal might need those switching and copying data procedures, could be challenging not as easy as I thought though…
need to edit reply for poor English, hope you don’t mind that :relaxed:

Hi,@QuantumCoderQC :slight_smile:
The approach you had suggested looks promising!
I tried setting bone matrix to specific rigid body for right upper leg control,
it ends up with Z axis shifting about 90 degree measured by eyes, it seems to be related to FBX bone axis system bias, I’m trying to solve this, is there a way commonly to deal with this kind of matrix math?
I’m getting excited to move a little bit forward!

best regards

Great!

If you would share the blend file you currently use (remember to pack in all external data), I could try to correct the rotation using rotation math nodes…

1 Like

Thanks,@QuantumCoderQC
I were trying another cheating way, hide ragdoll at beginning, show and move Rag-doll to target character with pose copied when event needs.

I initially tested some node settings and then got stuck with controlling the position of Rag-doll empty,it won’t work if position of Rag-doll is unable to change.If I have to turn off the “child of” setting for every bone then it’s meaningless again to use cheating way. :joy:

Another tricky thing is to process string name of rigid bodies and link to bone name input in Array loop, I used Sub String and Concatenate to convert output value of Array loop to match names in Armature for Get Bone Transform, and player halted for this.

Still struggling,it’s hard yet very interesting…

Yes, I did think about this. If the names of the bones and the rigid bodies match, then we do not even need a for loop. We simply apply a trait to all the rigid bodies. Each rigid body individually controls its corresponding bone.

For example if the name of the bone is “Bone” and the name of the RB is “Bone_RB”, then, each RB will control its own bone. No need to loop through all the bones / RBs

Yes! :slightly_smiling_face:

Also, please share your blend file.

@QuantumCoderQC:

My test file goes here

Press space to copy bone transform by processing “RB collection” out put to Array value names in a loop and convert them to match bone names.
Turns out that nothing happened.

Press V to copy Head bone matrix to TargetRB object, the axis seems not right, and press V again, then alternate to execute my string node setting to see if it can successfully convert simple string to bone name, and it doesn’t work neither, the node setting should work like text style coding way, but I don’t get it why it won’t work, furthermore I had no luck to set text to canvas element, it will halt for unknown reason.
Maybe RBs should be moved individually like you’d mentioned instead of moving with being parented.
The prior thing to solve is moving ragdoll to a position other than the world center, I found that if I move them with empty too far from its origin then the skin will distort, it’s confusing when they are parented to other object which owns their own origin.