• 3D
  • How to make a custom collider that will deform with a skeleton

I would like to make a collision detector for a mesh I have imported from blender. The mesh is parented to a skeleton, which I use to deform the mesh. I would like to attach a collider to it in order to implement physics and have other objects bounce off of it. Instead of attaching a general shape collider like a cube or sphere to the mesh, I want it to be an accurate copy of the mesh itself. I've tried adding a Trimesh Static Body, which does make a collider the same shape as the mesh, however since it's static, it won't deform with a skeleton. Is there a way to generate a collider the same shape as a mesh that would deform with a skeleton and also stay with the mesh as it moves around? I've tried to do this using physical bones, which I think is how you're supposed to do it, but I couldn't get it to work (the mesh would just go through other objects).

Thank you! Will look into this

How are you supposed to parent/implement this new node? My current structure is Spatial -> Spatial (armature) -> Skeleton -> Mesh. I'm not really sure where to add the collision shapes either

This tutorial might help. I haven't used it yet.

I tried following the tutorial, but I get this error message: Cannot get path of node as it is not in a scene tree. The skeleton is grayed out in my scene tree but I don't know why. Maybe it's because I imported it from blender or didn't import it correctly?

Actually I just found a node called BoneAttachement which is basically the same thing as the plugin and I got it working.

I'm able to attach mesh instances to the skeleton bones, and that works fine, but when I try to attach an area node with a collision shape child it doesn't work. (the other object is a rigidbody with a collision shape attached to it) How would you set up a collision where the rigidbody would collide with the skeleton and be prevented from entering the collision shape?

Hmm they must have added that bone attachment, that's probably why the plugin wasn't updated. That's good to know. What do you mean when you say you add a collision shape and it doesn't work. Does it give an error, or what?

Never mind, it was actually working how it was supposed to work. I thought that if I attached an area node with a collision shape to the skeleton, it would make rigid bodies bounce off it, but all that does is create an area that detects collisions and doesn't actually do anything. What I was trying to do is make it so that rigid bodies would not be able to enter the collision shape area on the skeleton. Is that possible? Maybe I could calculate the force of the rigid body and then when it touches the collision shape i would apply the opposite force? There's probably a better way but I can't find anything.

Did you try adding a kinematic body? If that doesn't work, then yeah, you would have to apply an opposite force.

Thank you so much for all the help! The kinematic body worked perfectly