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 Transform Child 组件可将游戏对象的子游戏对象的位置和旋转与 Network Transform 组件同步。如果需要同步某个联网游戏对象的独立运动子对象,则应使用此组件。
要使用 Network Transform Child 组件,请将其与 Network Transform 附加到同一个父游戏对象,然后使用 Target 字段来定义要将组件设置应用到的子游戏对象。在一个父游戏对象上可以设置多个 Network Transform Child 组件。
属性 | 功能 | |
---|---|---|
Network Send Rate (seconds) | 设置每秒的网络更新数。对于在创建后不需要更新的游戏对象,比如玩家生成的非交互式效果(例如,玩家身后的无法交互的尘埃云团),可以将此滑动条设置为 0。 | |
Target | 要同步的子变换。(请注意,此组件位于父对象而不是子对象上,因此应使用此字段指定子对象)。 | |
Movement Threshold | 设置在不发送移动同步更新的情况下游戏对象可以移动的距离。 | |
Interpolate Movement Factor | 使用此属性可启用和控制同步运动的插值。该数字越大,游戏对象插入到目标位置的速度越快。如果将其设置为 0,则游戏对象将贴靠到新位置。 | |
Interpolate Rotation Factor | 使用此属性可启用和控制同步旋转的插值。该数字越大,游戏对象插入到目标旋转的速度越快。如果将其设置为 0,则游戏对象将贴靠到新旋转。 | |
Rotation Axis | 定义应同步的一个或多个旋转轴。默认设置为 XYZ(全 3D)。 | |
Compress Rotation | 如果压缩旋转数据,则发送的数据量较低,旋转同步的精度较低。 | |
None | 选择此选项将不对旋转同步应用任何压缩。这是默认选项。 | |
Low | 选择此选项可对旋转同步应用低压缩量。此选项可减少为旋转数据发送的信息量。 | |
High | 选择此选项可对旋转同步应用高压缩量。此选项为旋转数据发送最少的信息。 |
此组件不使用物理系统,可同步子游戏对象的位置和旋转,并向更新后的值进行插值。使用 Interpolate Movement Factor 和 Interpolate Rotation Factor 可自定义插值的速率。
具有 Network Transform Child 组件的游戏对象还必须具有 Network Identity 组件。在某个游戏对象上创建 Network Transform Child 组件时,Unity 还将在该游戏对象上创建 Network Identity 组件(如果还没有此组件)。
NetworkTransformChild
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.