How-to : use deformers to animate a worm in Maya and Unity

Moderator: BenChang

How-to : use deformers to animate a worm in Maya and Unity

Postby BenChang » Mon May 05, 2014 8:29 pm

Screen Shot 2014-05-05 at 4.26.54 PM.png
Question from a student:
my character is a worm-like creature, but I am having trouble putting together an animation (in Maya) that looks realistic. I found that if I use the non-linear sine deformer on the mesh, it makes the effect look somewhat similar to an actual worm. The problem is that the deformer only affects the mesh, and nothing else, so once I import the object into Unity, the animation will simply show the worm moving forward in a
straight line.


This is neat, I've never actually played with the nonlinear deformers much in Maya. The Sine deformer creates a sine wave that you can use to create this wavy, rippling effect on your mesh that does look like a worm. But yes, it doesn't transfer to game engines like Unity, where you basically only have joints to work with.

Would blendshapes work? Maybe, but those are kind of iffy so far in Unity anyway, and there should be a better way. The best results, of course, will be from hand-animating the worm, perhaps using clusters on spline IK handles - but for a quick and simple in-game animation, the sine deformer is a good starting point.

The trick is to use that to drive joints, which you can't do directly but you can do via the spline IK tool.

1. make worm mesh
2. make a joint chain inside it. put enough joints that it will be able to bend and wriggle as much as you want.
3. smooth bind the mesh to the joint chain
4. create a Spline IK on the joint chain
5. select the curve for the Spline IK and rebuild it (in Surfaces, Edit Curve->Rebuild Curve), and give it more CV's. it needs enough CV's to take on the sine wave shape.
6. select the curve and create the sine wave deformer (in Animation, Create Deformer->Nonlinear->Sine)
7. rotate the sine deformer to the same orientation as your curve for the Spline IK
8. adjust the amplitude, wavelength, and offset on the sine deformer to animate it. (Note - you can set keys on these by R-click in the Attribute editor, but a better way would be to create a custom attribute called, say, "wriggle" on a main Worm control curve and use Set Driven Keys to drive the offset )

9. Bake the animation into the joints: select the root of the joint chain, go to Edit->Keys->Bake Simulation, make sure "Below" is checked. This should bake the sinewave motion into the joint rotations and it should now work when you export it to Unity.
User avatar
BenChang
 
Posts: 176
Joined: Mon Jan 17, 2011 4:48 pm

Return to Art and Animation

Who is online

Users browsing this forum: No registered users and 1 guest

cron