To start off you’ll want to use some geometry created in either Max or Maya. For this tutorial I’ll be using Maya. In general it seems like character development is easier in Maya, so I’ll be using that for most of my tutorials, but I’m quite aware that there are a lot of folks out there who know 3DStudioMax better. I also prefer to do environment modeling in Max as there are a lot of cool things that Max can do that Maya can’t. (specifically some UV tricks when pulling on verts.)
So to get started. First in Maya, or something like Maya make yourself a cube. It will have to be a substantial size so it will be large enough to see in your level.
Here I’ve started off with a cube and I added an edge loop around each corner. This will help keep the shape of the cube after it’s been subdivided. I changed the settings of the cube after it was created from the polygon menu to 128x128x128. The final result is something like what you see to the left.
I’m a huge fan of the Maya Hotbox, It’s been years since I’ve actually touched a regular menu in Maya. For me it’s a lot easier to use than the quad menu offered in Max.
So to sub-divide our cube right-click on the mesh and select Smooth.
Here I’ve added a lot of geometry to the original cube. The edge loops help keep the shape of the object and allowed us to add the vertices necessary for when this thing needs to be blobby shaped. If there are not enough vertices on the mesh then the soft body system will not have enough geometry to reshape the object nicely when running the simulation.
Next create a new Joint and put it into the center of the cube. Softbody objects require skeletal mesh information to let the engine know which vertices are going to be run by the simulation and which vertices are not. This should clue you into the fact that a character can have parts of him run by softbody simulation and the rest of the character is driven by regular animation.
Smooth skin the entire mesh to the single joint. And use the comand line to tell Maya to open the ActorX plugin. axmain will open the ActorX Skeletal mesh exporter so navigate to your export directory and then save the mesh as Meatcube.
Open UDK and click on the Import button in the content browser.
Create a new package for your Meatcube to live in. In this case I’ve named the UPK “MeatPackage” and since I exported the PSK from maya we’ll want to turn on the Assume Maya Coordinates check box. I didn’t bother adding the object into a specific group since this isn’t going to be a complex upk. Otherwise I might have added it to a meshes or a skeletalmeshes group inside of the package.
So next we’ll save the package in the Contents/Misc directory as MeatPackage.upk, this will make things easier to find. I’ve also provided my version of the MeatPackage.upk for you to take a look at. To change our regular skeletal mesh object into a softbody edit the skeletalmesh object and open it in the animset editor.
Scroll down in the properties window to the SoftBody roll out and add a new joint to the Soft Body Bones list. This will tell the editor which vertices are going to be controled by the simulation.
To make the simulation more interesting crank up the Soft Body Detail level and up the softbody subdivision level. These will be the only two changes over the default settings. It’s important to note here that if you dont have the subdivision level and the detail level high enough You’ll create a tetrahedron that’s too low detailed for the editor to generate a big enough volume. I’ve run into situations where the editor told me to increase these settings to create a proper softbody tetrahedron.
Another very important check box, Force CPUSkinning. This will tell the engine that you intend to do something using physics on the mesh. If you’ve got a geforce card then the CPUSkinning will take place on the graphics card’s physX processing system. Otherwise your multicore proc will have to run the simulation.
Click on the little green pyramid at the top of the AnimSet editor window. This will generate your softbody proxy mesh. You’ll see a crazy new object form around your Meatcube. This is the actual spring network of edges that will hold the objects shape.
To test your object’s softbody simulation toggle the preview simulation button on to the right of the generate tetra button. Your cube will fall and land on an invisible ground plane under the shape.
To play with the properties of the mesh go to the SoftBody roll out and play with the top two parameters. Lowering the stiffness and Stretchy properties will make the shape more squishy.
In a level you can add the object as a SkeletalMesh to your scene. At first this will not behave as expected, it’ll just be a regular skeletal mesh.
You’ll need to open the properties of the placed skeletalmesh in your scene and expand SkeletalMeshActor->SkeletalMeshComponent->SoftBody and turn on these flags for Enable Soft Body Simulation, Soft Body Active On Statup and in addition you’ll want to turn on the Soft Body RB Collide with Default. Not turning on the last default channel will not tell the soft body object it needs to collide with the world.
Here’s a basic scene with a dynamic light which is casting dynamic shadows, a player start for you to spawn at and the softbody cube. when you play the game the cube will fall to the ground and go squish. Right now you cant interact with the cube, but I’ll get into how to do that in the next tutorial!
Happy modding!