

Also stored at the beginning are a few parameters we use for calculating the in-between steps that we can use to slow down the motion, and the aforementioned step interval.įor the squat animation, we are going to save the parameters for body frame lean forward, desired height, left shoulder position, right shoulder position, and gyro ratio. We start the animation by telling the controller that we are starting an animation and saving the old parameters that we will be modifying, since we want to have the character revert to its original position after the animation is completed. The character is going to squat on keypress, hold the position for about a second, and then stand up. The first animation we are going to cover is a traditional squatting motion. M_controller.m_desiredPose.m_editAsEulers = true You can get the joint index via the joint name and allow editing as eulers by accessing the desired pose script object with the joint index: int m_jointName = m_rootTntBase.NameToIndex(“jointName”) The desired pose controller also needs to allow editing as eulers to use Vector3 for controlling rotation. When creating these animations, start by obtaining the joint index for each joint you will be editing in the animation. TntController.m_desiredPose.SetJointOrientationToEulers(jointIndex, jointOrientation) The functions you will be using for the majority of your animation scripts are: tntController.m_controlParams.m_params = parameterValue Additional parameters to specify is the step interval duration between each command and store the old position are required. This is not required when animating an Avatar character, but it is highly recommended.
#Unity learn procedural animaition code
We use this code tell the motor what angle we want the joint to reposition to and the Avatar character controller will take care of the rest.Įach command given to the controller is done as part of a coroutine, so we need to tell the controller to ignore other commands until the current animation is finished to prevent conflicting commands being given to the same limb.

The Avatar Runtime package doesn’t have a keyframe timeline of traditional animation, so let’s craft each of the Avatar character’s motions using C# code. This results in an animation that can adapt to how the rest of the body is being interacted with. The difference between this type of animation and traditional keyframe animation is that instead of controlling the position and location of each body part, you control the motion of each joint motor. We use C# to modify the controller parameters and desired pose to change the body positioning. This allows for the procedural animation of characters using simple scripting to puppeteer the character’s physical body. Characters created using Avatar can be animated in this way because they are physically simulated with a multitude of biomechanical parameters. The goal behind using procedural animation to move a character is to replace tedious keyframe animation cycles and to make characters interactive. ( DeepMotion Neuron, to be released later this year, will make make these procedural, physics-based movements even more natural looking, using animation data to train characters motor skills prior to run-time.) Physics Based Procedural Animation for Characters All the animations created using this technique will be completely procedural, physics-based movements. In this post, we will cover 3 motions (a basic squat animation, a waist rotation animation, and a kicking animation) that we have made with this process, and go over the steps for creating a new motion from scratch. This is an more advanced tutorial that requires some knowledge of C# and basic math. Now that you have constructed a physically simulated character that can stand in-place, self-balance, and walk what’s next? This tutorial shows you how you can drive your characters with unique, interactive, physically simulated actions via scripting. This blog post will serve as an introduction to one of the multiple procedural animation methods supported by DeepMotion Avatar: procedural animation for various character standing movements via C# scripting in the Unity editor.
