Creating a Mobile Game Prototype Using Maya LT & Unity – Part 3: Animating a hero character
Articles Blog

Creating a Mobile Game Prototype Using Maya LT & Unity – Part 3: Animating a hero character

August 9, 2019


In the previous movie, we assembled the platform sections and populated our game level in Unity. In this movie, we’ll focus on animating our hero Sven and integrating him into our level. In Maya LT, set the provided source assets folder as the current project, then open the file “sven_source.mlt”, or import the corresponding .fbx file in a new scene. This scene features our Sven character in a static t-stance pose, equipped with his jetpack. Notice Sven’s low polygon count, which is in keeping with the optimization best practices we introduced in the previous movie. We’re purposely using this level of detail, or “LOD”, because we know that his size onscreen in the game world will be smaller due to the camera framing. Because of that, there’s more value in opting for a low LOD versus a high one since it will be difficult to notice the difference. And remember that we can always “fake” polygonal details on our low LOD mesh using normal maps if necessary. Turn on XRay joints mode to display Sven’s skeleton over his mesh in the workspace. We skinned Sven to this HumanIK-generated skeleton, which is pre-configured for humanoid proportions. However, as we’re being mindful of the mobile platform we’re aiming to publish on, let’s further optimize this skeleton’s joint count. Determining which joints to keep and which to leave out is subject to technical and creative considerations. For example, if you don’t plan to animate certain joints, such as facial and finger joints, then you should consider removing them. Conversely, if you remove joints that impact the character’s mesh deformation, then it may be harder to read the resulting animation onscreen. Here we’ll apply a “middle of the road” approach. Since our character is already bound to a skinCluster deformer, it’s best to first detach that node before updating the skeleton. With Sven selected, go to Skin>Detach Skin [Options]. Set History to “Keep history” so Maya LT preserves the skinCluster deformer after it detaches it. This will allow us to re-attach it after our changes, saving us from re-skinning Sven from scratch. Select the head joint. In the Outliner, press F to frame it in the hierarchy. Expand its hierarchy and delete all its child joints, as well as the collar bend and the helmet collar joints. Using the same technique, delete all child joints under each hand. You can also remove the joint chain associated with Sven’s laser cannon. Finally, we’ll remove some of the roll joints from the hierarchy. In the Outliner’s filter box, type “*Roll*” to only list objects containing that word. Expand all hierarchies by holding Shift as you click them. Then delete all roll joints except for the upper roll joints in the arms and legs. Now to re-bind Sven to his skinCluster node, select him and his root joint, then go to Skin>Bind Skin>Smooth Bind. Note that you may have to adjust Sven’s skin weights in areas corresponding to the removed joints. Use the Paint Skin Weight tool to redistribute skin weights where needed. We’ve provided a repainted result scene in the source assets folder. Next, let’s move on to creating a hovering animation for Sven. For this, we’ll use the HumanIK animation toolset, which you can activate by going to Skeleton>HumanIK. HumanIK lets you animate your character realistically using a full-body IK control rig. In order to create this control rig, HumanIK first needs to understand your character’s skeleton hierarchy and proportions. For this we go through a skeleton definition process, also known as “characterization”. Under Define, click the Skeleton button. In order to properly define your skeleton, you must map each cell in this Character view to a corresponding skeleton joint. You can either do this manually … … or load a skeleton definition template, which we’ve provided in the source assets folder. To learn more about the intricacies of the HumanIK characterization process, refer to the HumanIK playlist on this channel. Click the Lock Skeleton Definition button, and set Source to “Control Rig”. You can now use the full-body IK control rig to pose Sven. Use the Body Part and full Body keying and manipulation modes to help you achieve the desired pose. In Body Part mode, each IK control curve, or effector, controls independently from one another, similar to a traditional rig. In Full Body mode however, one IK effector can affect the rest of the body, just like a ragdoll marionette. With your first pose created, select all effectors by clicking an empty part of the Character representation. Go to Animate>Set Key to create a new keyframe for the selected effectors at frame 1. Then right-click the key set at frame 1, and choose Copy. Go to frame 61 and paste that key. Now that we’ve defined the start and end point of our 60 frame hovering cycle, we can create additional poses to make this animation more dynamic. Make sure you enable Auto Keyframe mode so Maya LT automatically records each change you make. At frame 30, create a pose variation by lowering the hips effector a bit and repositioning the feet effectors to create a different hovering silhouette. To add more randomness to the leg motions, add another key at frame 15 for only one leg effector, and another at frame 45 for the other. You can also twist and rotate the hips and spine effectors to simulate some weight changes, as if Sven is trying to maintain his balance as he hovers. With the hovering animation finished, we can shift our focus to exporting it to our game level. However, notice that the animation keys we set are only on the HumanIK control rig and not on the skeleton that we optimized earlier. That’s because the control rig still drives the skeleton. To transfer the animation over, we need to bake down the animation keys onto the skeleton using the “Bake To Skeleton” command. Now each joint contains a key at every frame of our timeline. Set the end time of the animation to 60 so the hovering cycle is seamless. In the Layer Editor, select the Skeleton layer and go to Layers>Select Objects in Selected Layers. Then Shift-select both Sven and his jetpack, and export that selection. Name the resulting FBX file “sven.fbx”, then set the preset to “Autodesk Media & Entertainment”. Under Animation, the enabled “Animation” option ensures that Maya LT exports the animation keys on the selected objects. Leave the Bake Animation option disabled since we already baked down our animation. Under FBX File Format, make sure you’re using “FBX 2014”. Click Export Selection. Copy the Textures folder from your local “HSM_Game_Source” folder to your Unity project’s Assets folder. In Unity, select Sven in the Project view. In the Inspector’s Model tab, set Material Naming to “From Model’s Material”. In the Rig tab, notice the different animation types. For the scope of this tutorial, we’re going to use the ‘Legacy’ type, which provides a simple animation framework. In the Animations tab, set Wrap Mode to Loop. Drag Sven into the Hierarchy, which centers him in the scene. Place him over the first ramp section. Rotate him -90 degrees in the Y axis so he faces towards the level, and scale him twice his original size in all three axes. To test the result in the Game view, we’ll reposition the camera to better frame Sven. First rotate it 180 degrees in the Y axis, then set its position to -8, 8, and 15 in the X, Y, and Z axes, respectively. Save your game, then press the Play button to go into Play mode. Sven hovers over our level, awaiting a challenge in the dark. In the next movie, we’ll light up the game world and assemble the building assets to add to the background scenery.

Only registered users can comment.

  1. Since you shown how to setup single animation to single character i was wondering if its possible (and if so how) to atach multiple animations (floating, running and others) to single character and export them to unity.

  2. Mate i need your help.I want to create game with Unity for Android and iOS i have Great Idea.But i dont know how to make images,characters .. please 

  3. By copying the keyframe from 1 to 61, Maya  crashes.
    Solution: maintaining the same pose, key @ Frame 1 & another @ Frame 61.

  4. Well presented! (=

    By the way, is it ok if i can get your advice on these android app below? I am still a beginner and hope to learn from everyone. Your feedback is greatly appreciated!…

    Kindly search ' pub:Path Ahead ' in Play Store (P & A are case sensitive).

    thanks alot !!

Leave a Reply

Your email address will not be published. Required fields are marked *