Important: UNet is a deprecated solution, and a new Multiplayer and Networking Solution (Netcode for GameObjects) is under development. For more information and next steps see the information on the Unity Netcode for GameObjects website. |
Network Animator 组件可以同步联网对象的动画状态。此组件可同步 AnimatorController 中的状态和参数。
请注意,如果在空游戏对象上创建 Network Animator 组件,那么 Unity 还会在该游戏对象上创建 Network Identity 组件和 Animator 组件。
属性 | 功能 |
---|---|
Animator | 使用此字段可定义希望与 Network Animator 同步的 Animator 组件。 |
The Network Animator ensures the synchronisation of GameObject animation across the network - meaning that all players see the animation happen at the same. There are two kinds of authority for networked animation:
如果游戏对象在客户端上具有授权,则应在拥有此游戏对象的客户端本地对游戏对象进行动画化。该客户端将动画状态信息发送到服务器,服务器再将此信息广播到所有其他客户端。例如,这种授权方式适合于玩家角色。
如果游戏对象在服务器上具有授权,那么应该在服务器上对游戏对象动画化。然后,服务器将状态信息发送到所有客户端。这种授权方式对于与特定客户端无关的动画化游戏对象(如非玩家角色)很常见。
Network Animator 将同步在 Inspector 窗口中选中的动画参数。该组件不会自动同步动画触发器。具有授权的游戏对象可以使用函数 SetTrigger 在其他客户端上触发动画触发器。
可使用 GetParameterAutoSend 和 SetParameterAutoSend 函数来控制应自动同步的各个动画器参数。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.