售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Unity Character Animation with Mecanim
Table of Contents
Unity Character Animation with Mecanim
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
The context
What this book covers
What the book does not cover
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. The Zombie Attacks!
Setting up the project
Importing our enemy
Organizing the material and textures
Adjusting the import scale
Adjusting the rig import settings and creating the Avatar
Choosing the appropriate rig import settings
Creating the Avatar
Adjusting the character's pose
Checking the bone hierarchy in the Avatar
Setting up the animator controller
Creating states
Creating a parameter
Adding transitions
Writing the script
Adjusting the scene elements to preview the animation
Previewing the hit animation in the game view
Summary
2. Rigging Characters for Unity in 3ds Max and Maya
Understanding the need for rigging
Minimum requirements
Sourcing models
Modeling for animation
Rigging in 3ds Max
Setting up the scene
Importing the character model
Creating the Biped system
Adjusting the Biped's parameters
Adjusting the Biped to fit the character
Switching to X-ray mode and freezing the character mesh
Changing bone display colors
Scaling and orienting the bones to match the character model
Repositioning the joints for the ponytail and jaw
Adjusting limb positions
Renaming bones
Copying and pasting the position, rotation, and scale data from one side to the other
Skinning the character using the skin modifier
Creating a selection set
Saving the default pose
Creating the test pose
Making adjustments to the Skin modifier
Adjusting envelopes
Adjusting influence on the head vertices
Painting skin weights for the jaw bone
Exporting the rigged character
Rigging in Maya
Setting up Maya to rig our character model
Setting system units to meters
Changing the display grid size
Importing the model
Adjusting the model scale
Adjusting the viewport display and toolset for joint creation
Creating joints for the back, neck, and head
Renaming and repositioning the joints
Creating the leg joints
Creating the arm joints
Cloning the finger joints
Mirroring joints for the leg and arm chains
Connecting the arm and leg chains
Creating the ponytail and jaw joints
Aligning joint transforms
Creating a test pose
Binding the character mesh to the skeleton
Painting skin weights
Exporting for unity
Summary
3. Interacting with the Environment
Importing the project assets package
Setting up the player character
Creating a new scene
Adding the player character model to the scene
Adding the character controller
Adjusting the camera height
Adding the shoot idle animation
Adding and parenting the gun
Saving the first-person rig as a prefab
Adding the office-level scene
Completing the camera setup
Modifying the animator controller
Setting the transition
Creating a trigger parameter for the Shoot state
Writing and implementing the character animation script
Adding the initial code to the FPSAnimation script
Adding the script to the player character game object
Adding and implementing collectable objects
Instantiating the lunchBox collectable in the game level
Inspecting the lunchBox collectable's components
Looking at the collectable script
Implementing self destruction in the collectable script
Setting up the player character's response
Adding the Pickup state to the animator controller
Setting the Pickup state's transitions and parameter
Transitioning between the ShootIdle and Pickup states
Creating and adding the parameter
Creating the pickup camera
Finalizing the pickup camera prefab
Looking at the player status script
Adding the PlayerStatus script to the player character game object
Updating the Collectable script
Hooking up variables in the collectable script
Updating the FPSAnimation script
Modifying the pickup script
Testing the lunchBox collectable
Summary
4. Working with Motion Capture Data
Introduction to motion capture sequences and their characteristics
Using a motion capture sequence with a pre-rigged model
Getting started
Importing the motion capture sequence
Adjusting the import settings
Adjusting the rig import settings
Adjusting the sequence in the Animations tab
Creating the second walk cycle
Adding the new motion clips to the animation controller
Creating a script to see both animation loops in action
Adding the script and previewing the animation switch
Summary
5. Retargeting Animation
Loading the scene
Adding and previewing the animation
Adjusting import settings to get a better fit
Creating a duplicate walk cycle
Adjusting the motion parameters
Adjusting the muscle limits
Working with Avatar Body Masks
Opening the new scene
Creating a second layer in the animator controller
Creating states in the mask layer
Setting the parameter and transitions in the mask layer
Editing the script
Previewing the masked animation
Creating five walk variations from two walk cycles
Adding more Avatar masks
Summary
6. Talking Heads
Adding the snarl face animation to the female zombie character
Setting the scene in Unity
Adding code to the zombie_ready script
Adding the TurnToPlayer function
Connecting the variables in the Inspector panel
Updating the animator controller to include the face animation
Adding the Snarl state
Creating a Null state
Setting transitions between the Null and Snarl states
Creating the IsSnarling parameter
Editing the script to include the Face layer
Smoothing the zombie's turn rotation
Implementing the turn animation
Adding the turning state
Setting up the IsTurning parameter
Creating the transitions to connect the turning state
Setting the transitions for the Turn state
Updating the zombie_ready script to accommodate the Turn state
Creating the Snarl function
Synchronizing the snarl sound
Driving a blendshape animation with the animator controller
Viewing the blendshape in Unity
Keyframing the face blendshape
Updating the animator to handle the blendshape animation
Summary
7. Controlling Player Animation with Blend Trees
Adding a Blend Tree to the player's existing animator controller
Adding strafing animation to the player character with a Blend Tree
Using Blend Tree properties
Adding the motion clips to the Blend Tree
Adding and adjusting the Blend Tree parameters and thresholds
Updating the character script to use the Blend Tree
Testing the Blend Tree in the Game View
Varying the pickup animation with a Blend Tree
Viewing the pickup_heavy animation sequence
Creating a Blend Tree in the Pickup state
Setting the pickup Blend Tree parameter
Setting the threshold for the pickup Blend Tree
Editing the character animation script to accommodate the pickup Blend Tree
Updating the Collectable script to include a weight variable
Sending the objectWeight variable
Updating the Pick function in the character animation script
Testing the blended animation in the game
Instancing the collectable prefabs
Previewing the blended animation
Summary
8. Implementing Ragdoll Physics
Introduction to joints in Unity
Creating a test scene
Adding a hinge joint
Creating the ragdoll object
Assigning the material
Generating the initial ragdoll
Assigning bones to the ragdoll list
Assigning mass
Previewing the default ragdoll
Adjusting collision objects
Adjusting the radius of the capsule collider to fit the leg
Adjusting the head's collider
Fine-tuning the character joints
Adjusting the rotational limits of the upper arm
Adjusting the rotational limits of the forearm
Adjusting the rotational limits of the head
Previewing the adjusted ragdoll
Adding a custom joint to the ragdoll
Adding a capsule collider to the ponytail
Adding a Rigidbody component
Adding the character joint
Saving the ragdoll as a prefab
Summary
9. Controlling Enemy Animation with AI and Triggers
Implementing range detection
Looking at the scene
Adding the initial AI script
Adding proximity detection to the enemy AI script
Setting up the patrol behavior
Adding variables for the patrol
Adding the initial patrol code to the Update function
Defining patrol points
Modifying the animator
Adding and accessing an animation curve
Accessing the animation curve in Mecanim and using it in the script
Adding the attack
Adding the Attack state
Associating tags with the enemy and player game objects
Allowing the zombie to hurt the player
Damaging and killing the zombie
Allowing the player to fire
Pathfinding and obstacle detection with navMesh
Suspending navigation during the turn
Adjusting navigation during the attack
Modifying the Attack function
Timing out the zombie's pursuit
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜