12
Unity3D Animation

Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

Embed Size (px)

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

Page 1: Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

Unity3D

Animation

Page 2: Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

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.

Page 3: Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

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.

Page 4: Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

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.

Page 5: Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

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?

Page 6: Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

Animation Blending• Void Update()• {

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

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

animation.CrossFade(“idle”);}

}

Page 7: Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

Animation Layers• Void Start () {

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

}

Page 8: Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

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

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

}

Page 9: Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

Using Animation Eventsfunction PrintFloat (theValue : float) {

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

}1

2

3

Page 10: Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

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; }

Page 11: Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

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.

Page 12: Unity3D Animation. The Animation System supports –animation blending, –mixing, –additive animations, –walk cycle time synchronization, –animation layers,

Quality