Unity 3 D Animation Animation The Animation System












- Slides: 12
Unity 3 D Animation
Animation • The Animation System supports – animation blending, – mixing, – additive animations, – walk cycle time synchronization, – animation layers, – control over all aspects of the animation playback (time, speed, blend-weights), – mesh skinning with 1, 2 or 4 bones per vertex as well as supporting physically based rag-dolls and procedural animation.
Animation. Clip • Stores keyframe based animations. • length Animation length in seconds (Read Only) • frame. Rate Frame rate at which keyframes are sampled (Read Only) • wrap. Mode Sets the default wrap mode used in the animation state.
Wrap. Mode • Once – When time reaches the end of the animation clip, the clip will automatically stop playing. • Loop – When time reaches the end of the animation clip, time will continue at the beginning. • Ping. Pong – When time reaches the end of the animation clip, time will ping pong back between beginning and end. • Default – Reads the default repeat mode set higher up. • Clamp. Forever – Plays back the animation. When it reaches the end, it will keep playing the last frame and never stop playing.
Animation. State • In most cases the Animation interface is sufficient and easier to use. • Variables enabled Enables / disables the animation. weight The weight of animation wrap. Mode Wrapping mode of the animation. time The current time of the animation normalized. Time The normalized time of the animation. speed The playback speed of the animation. 1 is normal playback speed. normalized. Speed The normalized playback speed. length The length of the animation clip in seconds. layer The layer of the animation. When calculating the final blend weights, animations in higher layers will get their weights – clip The clip that is being played by this animation state. – name The name of the animation – blend. Mode Which blend mode should be used? – – – – –
Animation Blending • Void Update() • { } If(Input. Get. Axis(“Vertical”) > 0. 2 f) { animation. Cross. Fade(“walk”); }else { animation. Cross. Fade(“idle”); }
Animation Layers • Void Start () { animation. wrap. Mode = Wrap. Mode. Loop; animation["shoot"]. wrap. Mode = Wrap. Mode. Once; animation["shoot"]. layer = 1; animation. Stop(); }
Animation Mixing • void Start () { Transform mix. Transform; mix. Transform = transform. Find("root/upper_body/left_shoulder"); animation["wave_hand"]. Add. Mixing. Transform(mix. Transform); }
Using Animation Events function Print. Float (the. Value : float) { Debug. Log ("Print. Float is called with a value of " + the. Value); } 1 2 3
Additive Animation Example private var lean. Left : Animation. State; private var lean. Right : Animation. State; function Start () { lean. Left = animation["lean. Left"]; lean. Right = animation["lean. Right"]; lean. Left. layer = 10; lean. Right. layer = 10; lean. Left. blend. Mode = Animation. Blend. Mode. Additive; lean. Right. blend. Mode = Animation. Blend. Mode. Additive; //하략} function Update () { var lean = Input. Get. Axis("Horizontal"); lean. Left. normalized. Time = -lean; lean. Right. normalized. Time = lean; }
Modeling Optimized Characters • • Use one Skinned Mesh Renderer – Your character should use only a single skinned mesh renderer. – You also want to keep the number of materials on that mesh as low as possible. – Medium Desktop games use bone hierarchies with 15 -60 bones. The fewer bones you use the faster; with 30 bones you can achieve very good quality on Desktop platforms and fairly good quality on Mobile Platforms. . Don't Use Many Materials Reduce Amount of Bones Polygon Count – • Separate Out IK and FK – • Separate out inverse kinematics (IK) and forward kinematics (FK). When animations are imported, the IK nodes are baked into FK, thus Unity doesn't need the IK nodes at all. Use Reusable Rigs – • How many polygons you should use depends on the quality you require and the platform you are targeting. Anything between 300 -1500 triangles on Mobile Platforms and 500 -6000 triangles on Desktop Platforms is reasonable. Create a rig which you can reuse. This allows you to share animations between different characters. Name Bones Correctly – Name the bones correctly (left hip, left ankle, left foot etc. ). Especially with characters, naming your bones correctly is very important.
Quality