Hello forum! I have a question for attaching colliders to my 3D rigidbody.
I’m working on a very large creature in my game that the player can walk around on and also ride on. The creature is about 20x the size of the player. The creature is a rigidbody with a custom controller on it. The creature is fully rigged and animated, so when you turn left or right while controller the animal its head and neck will turn left or right, etc. Since its bones are moving through animations and walk cycles I need the creatures colliders to move with those animations.
The creature has a main object with a Rigidbody and a very small collider attached to it. This is supposed to be the collider that handles all the movement. Then a child object with the controller script, then a child object for the model, and below that are the model components such as the rig and all the bones, etc.
I’ve tried attaching colliders to the individual bones but that just makes the rigidbody go all crazy as I’ve learned now that all colliders under a rigidbody get combined into one.
So I’m curious how I can go about having different colliders on different bones for my rigidbody? How do other games with large moving creature that you can walk or climb on do it?
This is far from trivial. For starters, try having kinematic rigidbodies attached to every bone in your character, and making sure the animator is set to “Animate physics”.
Colliders attach to the first rigidbody they find up their hierarchy, including the object they’re sitting on. Having a kinematic rigidbody and a collider at each bone means these colliders will be attached to the rigidbody in the same bone. Being kinematic, the rigidbodies won’t be affected by gravity or external forces. Making sure the animator is updated in the physics loop means the rigidbodies will be driven by the animation instead, and allow other non-kinematic rigidbodies to interact properly with them.
Thanks so much for the suggestion! I tried this out and it works properly when colliding with other Rigidbodies now which is perfect.
I should’ve mentioned this in the original post, but I also need these “bone colliders” to collide with static objects as well, such as terrain. Would that be possible? Since they are kinematic they won’t be able to collider with other non-rigidbodies so I’ve tried making each rigidbody on each bone non-kinematic while freezing the rotation and position. Unfortunately it’s not registering any collision even then and just clips right through any static colliders.
I’ve also tried keeping them kinematic and changing the Contact pairs mode to “Enable Kinematic with Static Pairs” but that also doesn’t seem to work.