简体   繁体   English

是否有必要在worldUpdate中包含物理学是确定性的GameObjects?

[英]Is it necessary to include GameObjects whose physics are deterministic in worldUpdate?

In order to reduce data transfer size and the computational time for serializing world objects for each worldUpdate, I was wondering if it is possible to omit syncs for objects whose physics can be entirely, faithfully simulated on the client-side gameEngine (they are not playerObjects so playerInput does not affect them directly, and their physics are entirely deterministic). 为了减少数据传输大小和为每个worldUpdate序列化世界对象的计算时间,我想知道是否可以省略物理可以在客户端gameEngine上完全忠实模拟的对象的同步(它们不是playerObjects所以playerInput不直接影响它们,它们的物理特性完全是确定性的)。 Interactions with these GameObjects would be entirely handled by GameEvents that are much less frequent. 与这些GameObjects的交互完全由GameEvents处理,而这些GameEvents的频率要低得多。 I feel like this should be possible if the client is running the same physics as the server and has access to the same initial conditions. 如果客户端运行与服务器相同的物理并且可以访问相同的初始条件,我觉得这应该是可能的。

When I try to omit GameObjects from subsequent worldUpdates, I see that their motion becomes more choppy and they move faster than if they were not omitted; 当我尝试从后续的worldUpdates中省略GameObjects时,我发现它们的运动变得更加不连贯,并且它们的移动速度比没有省略时更快; however, when I stop the game server while keeping the client open, their motion is more like what I would expect if I hadn't omitted them. 然而,当我在保持客户端打开的同时停止游戏服务器时,如果我没有省略它们,它们的动作就更像我期望的那样。 This is all on my local machine with extrapolation synchronization. 这是在我的本地机器上进行外推同步。

The short answer is that the latest version of Lance (1.0.8 at the time of this writing) doesn't support user omission of game objects from world updates, but it does implement a diffing mechanism that omits objects from the update if their netScheme properties haven't changed, saving up on bandwidth. 简短的回答是Lance的最新版本(撰写本文时为1.0.8)不支持用户从世界更新中省略游戏对象,但它确实实现了一种差异机制,如果他们的netScheme省略了更新中的netScheme属性没有改变,节省了带宽。

This means that if you have static objects, like walls, for example, they will only get transmitted once for each player. 这意味着,如果你有静态物体,例如墙壁,它们只会为每个玩家传输一次。 Not transmitting this at all is an interesting feature to have. 根本不传输这个是一个有趣的功能。

If objects you're referring to are not static, then there is no real way to know their position deterministically. 如果你所指的对象不是静态的,那么就没有真正的方法可以确定地知道它们的位置。 You might have considered using the world step count, but different clients process different world steps at different times due to the web's inherent latency. 您可能已考虑使用世界步数,但由于Web固有的延迟,不同的客户端会在不同的时间处理不同的世界步骤。 A client can't know what is the true step being handled by the server at a given point in time, so it cannot deterministically decide on such an object's position. 客户端无法知道服务器在给定时间点处理的真正步骤是什么,因此无法确定性地决定此类对象的位置。 This is why Lance uses the Authoritative server model - to allow one single source of truth, and make sure clients are synched up. 这就是为什么Lance使用权威服务器模型 - 允许一个单一的事实来源,并确保客户端同步。

If you still want to manually avoid sending updates for an object, you can edit its netScheme so that it doesn't return anything but its id, for example: 如果您仍想手动避免为对象发送更新,则可以编辑其netScheme以便除了其id之外不会返回任何内容,例如:

static get netScheme() {
    return {       
        id: { type: Serializer.TYPES.INT32 }
    };
}

Though it's not a typical use due to the aforementioned reasons, so if you encounter specific sync issues and this is still a feature you're interested in, it's best if you submit a feature request in the Lance issue tracker . 虽然由于上述原因,这不是典型用途,但如果您遇到特定的同步问题并且这仍然是您感兴趣的功能,那么最好在Lance问题跟踪器中提交功能请求。 Make sure to include details on your use case to promote a healthy discussion 确保包含有关用例的详细信息,以促进健康的讨论

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM