Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the transition of 3D characters' facial expressions by Unity

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the knowledge of "how to realize the transition of facial expressions in 3D characters by Unity". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Catalogue

I. Preface

2. BlendShape (animator, MAYA)

3. Unity controls BlendShapes

1. SkinnedMeshRenderer controls BlendShape

2. Animation controls BlendShape

I. Preface

In the Unity project, we may need to implement the transition of 3D character expressions, such as this:

How do you do this in Unity? I'm going to tell you about it today.

2. BlendShape (animator, MAYA)

In Maya, animators can bind good expressions with BlendShape. Animators only need to make An expression, B expression, C expression and so on. The interpolation transition between expressions can be easily carried out through BlendShape.

Note that BlendShape is different from bone animation, which first binds the mesh to bones, which drives the mesh, while BlendShape does not need bones, so BlendShape is very suitable for the implementation of facial expressions.

After the animator completes the BlendShape, the Unity client programmer imports the model into the Unity project and checks the Import BlendShapes of the model in Unity.

In this way, we can adjust the transition of expression through the BlendShape slider in Unity.

The effect is as follows:

3. Unity controls BlendShapes

Above we are manually adjusting the slider of BlendShape, how can we control BlendShape through code?

There are two ways:

1. Access BlendShape directly through SkinnedMeshRenderer components

2. Make it into Animation, control BlendShape in Animation, and then control Animation by code.

1. SkinnedMeshRenderer controls BlendShape

Interface:

/ / SkinnedMeshRenderer.cspublic void SetBlendShapeWeight (int index, float value)

The parameter index is the index of BlendShape, starting at 0, and the parameter value is the value of the slider, in the range of 0,100.

2. Animation controls BlendShape

Animators make expressions into Animation, and a specific combination of BlendShape is actually an expression, such as eyebrows raised, eyes wide open, and mouth open. These three expressions are combined to make n Animation animations.

Organize these animations into Animator state machines.

About the use of Animator, you can see my previous article: a tutorial on the use of Unity Animation State Machine Animator

Then, we can realize the transition of facial expression by playing animation.

/ / Animator.cspublic void CrossFade (string stateName, float normalizedTransitionDuration)

The parameter stateName is the animation state name, such as smile, and the parameter normalizedTransitionDuration is the animation fusion normalization time.

We can test the fusion effect when the normalizedTransitionDuration is 0,0.3f and 1 respectively:

In the case of 0:

The case of 0.3f:

If it is 1:

This is the end of the content of "how to achieve the transition of facial expressions in 3D characters with Unity". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report