Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive...

Preview:

DESCRIPTION

AnimationClip Stores keyframe based animations. length Animation length in seconds (Read Only)length frameRate Frame rate at which keyframes are sampled (Read Only)frameRate wrapMode Sets the default wrap mode used in the animation state.wrapMode

Citation preview

Unity3D

Animation

Animation• The Animation System supports – animation blending, – mixing, – additive animations, – walk cycle time synchronization, – animation layers, – control over all aspects of the animation play-

back (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.

AnimationClip• Stores keyframe based animations.

• length Animation length in seconds (Read Only)

• frameRate Frame rate at which keyframes are sampled (Read Only)

• wrapMode Sets the default wrap mode used in the animation state.

WrapMode• Once

– When time reaches the end of the animation clip, the clip will au-tomatically stop playing.

• Loop – When time reaches the end of the animation clip, time will con-

tinue at the beginning.• PingPong

– 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.

• ClampForever – Plays back the animation. When it reaches the end, it will keep

playing the last frame and never stop playing.

AnimationState• In most cases the Animation interface is sufficient and easier to use.

• Variables– enabled Enables / disables the animation.– weight The weight of animation– wrapMode Wrapping mode of the animation.– time The current time of the animation– normalizedTime The normalized time of the animation.– speed The playback speed of the animation. 1 is normal playback speed.– normalizedSpeed 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– blendMode Which blend mode should be used?

Animation Blending• Void Update()• {

If(Input.GetAxis(“Vertical”) > 0.2f){

animation.CrossFade(“walk”);}else{

animation.CrossFade(“idle”);}

}

Animation Layers• Void Start () {

animation.wrapMode = WrapMode.Loop; animation["shoot"].wrapMode = WrapMode.Once; animation["shoot"].layer = 1; animation.Stop();

}

Animation Mixing• void Start () { Transform mixTransform; mixTransform = transform.Find("root/upper_body/

left_shoulder"); animation["wave_hand"].AddMixingTransform(mixTransform);

}

Using Animation Eventsfunction PrintFloat (theValue : float) {

Debug.Log ("PrintFloat is called with a value of " + the-Value);

}1

2

3

Additive Animation Ex-ample

private var leanLeft : AnimationState; private var leanRight : AnimationState; function Start () {

leanLeft = animation["leanLeft"]; leanRight = animation["leanRight"];

leanLeft.layer = 10; leanRight.layer = 10; leanLeft.blendMode = AnimationBlendMode.Additive; leanRight.blendMode = AnimationBlendMode.Additive;//하략 }function Update () { var lean = Input.GetAxis("Horizontal"); leanLeft.normalizedTime = -lean; leanRight.normalizedTime = lean; }

Modeling Optimized Characters• Use one Skinned Mesh Renderer

– Your character should use only a single skinned mesh renderer. • Don't Use Many Materials

– You also want to keep the number of materials on that mesh as low as possible. • Reduce Amount of Bones

– 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..

• Polygon Count– 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.

• 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

– Create a rig which you can reuse. This allows you to share animations between different charac-ters.

• 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

Recommended