The trouble with dragon collisions, part 3


SO.  In previous episodes, I was having trouble setting up the collision mesh for my animated dragon wings for various (now embarrassing) reasons.  Today while working on creating googly-eyes for an entirely different game, I hit upon the solution for Dragon Dozer.

It’s simple.  In Unity, you can place a variety of primitive objects, which are created with their own, form fitting collider component.  They are very easy to place in the scene and scale, move and rotate.  I knew that.  What I didn’t know, was that you can parent the actual primitive — not just the collider, but the actual editable primitive object — to the animated bone of another object: dragon wing bones, for example.  All you have to do to make the collisions work for the parent object then, is to “turn off” the mesh renderer component of the primitive objects.

What I was trying to do was edit the collider components applied directly to bones, which is exceedingly difficult to do.  Any time you click anything but the tiny edit points on the collider in edit mode, edit mode is turned off and you have to go back and enable it again.

I know I had seen mention of this method of parenting primitive meshes to individual bones of an animated model before as I was searching for a solution, but for some reason I always thought people were referring to the collider components themselves as “primitives” because 3D colliders come in sphere, capsule, cube and plane.

What made the lightbulb come on for me today was trying to set up collisions on a modeled plastic googly eye.  You see, you can’t simply put one object with a collider (the little plastic pupil that wiggles around), inside of another object with a collider (the plastic dome container).  When you try it and push play, the containing collider pushes the inner container out faster than a bunny making babies.

The answer then, is that you have to make a thin “shell” out of multiple colliders, whose outsides resist intrusion as intended, and this is called a compound collider.   Here’s a sneak peek at my silly setup:


I am in no way endorsing this setup, it just happens to be what I’ve found actually works to contain the pupil part without spitting it out.

There you have it, the proverbial two birds, non-lethally contained in one (compound) collider (or in other words, two problems solved with one solution.  Yay!  I spent the afternoon outfitting my dragon wings with colliders that move with the bones, and now my projectile physics work as intended and I am happy as a clam!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s