- Home /
How to animate level mesh with collider?
I've created a model in Blender that contains a single object with an Armature associated. The Armature contains separate bones for each loose collection of vertices in my object, with vertex groups assigned to each bone. I then created an animation of panels opening and a ramp extending.
I've been importing my .blend files into Unity and generating mesh colliders for the basic level geometry. My understanding is that Unity drops the mesh collider generation when animations are imported because you can't animate a mesh collider. I can settle for using primitive colliders, but I'm kind of clueless as to where to go from here.
How would I go about animating the ramp with associated primitive mesh colliders? Any good resources for Unity level (not character) animation?
Should I not be animating the model within Blender if I can be doing it in Unity? Is it easier to just handle everything within the same system?
If I'm going to stick with Blender for animating, I'm not really clear on how to set up multiple animations (with proper naming). Also, is it 'correct' to keep things the way I have it, as one object, or should it be broken up as one object per separate piece?
I did find this tutorial that covers animating levels with $$anonymous$$ecanim, but their door covered only a simple box collider, not a complex collider situation like I have. And it does seem like it'd be easier to build the animation in Blender and import that in, then use the Animation States to manage them.
I've noticed I can apply colliders to the individual parts within my model, but the ramp in particular gets pretty wonky. A box collider added to the ramp part itself gets rotated around in a crazy fashion and is impossible to line up with the actual ramp section. I'm assu$$anonymous$$g this has something to do with the rotation angles Blender used. The items that didn't rotate don't seem to have this issue.
I'll probably try refining the animation within Blender, and try the approach of multiple box colliders applied to the animations, and try using $$anonymous$$ecanim to move everything around. Any advice is still welcome, but I'll update this thread if I can resolve it myself.
Answer by Schneider21 · Jan 07, 2015 at 03:19 AM
Well, I believe I've figured it out.
I decided to go with Mecanim after all, and not import animations from Blender. I did leave the Armature in place, but applied no animations to it prior to importing.
I created 4 animation states within an animation controller: Ramp Open, Ramp Closed, Opening, and Closing. Each corresponded to an animation loop (two of which were just single frames of the open/closed position). I then set up logic to transition between the states depending on a boolean value (triggered) or through completion of the opening/closing state.
As I anticipated, adding the box colliders was much easier once I imported the model with each bone at nice, flat angles. So the ramp, which previously was imported at the open state, was imported at the closed state where it's flat. The collider, when applied to that particular piece of the armature, would then follow along with the object throughout its animation phases.