简体   繁体   English

在类似于 Diep.io 的自上而下多人游戏中处理射击的最佳方法?

[英]Best way to handle shooting in top down multiplayer game similar to Diep.io?

Im using Unity with Lidgren networking library(server - client architecture) to develop game with perspective and look similar to Diep.io.我使用 Unity 和 Lidgren 网络库(服务器 - 客户端架构)来开发具有视角的游戏,看起来类似于 Diep.io。

I trying to make shooting smooth on both sides, however, because of latency, if client is moving while shooting, client can see that bullet is created a bit further from player(last position that server received from client).我试图让双方的射击都顺畅,但是,由于延迟,如果客户端在射击时移动,客户端可以看到子弹距离玩家更远(服务器从客户端收到的最后一个位置)。

Currently to shoot, client sends packet to server, and server creates bullet at client position.当前要拍摄,客户端向服务器发送数据包,服务器在客户端位置创建子弹。

How does games like Diep.io handles shooting without any noticeable delay?像 Diep.io 这样的游戏如何在没有任何明显延迟的情况下处理射击?
How would you handle shooting in game similar to Diep.io?在类似 Diep.io 的游戏中,你会如何处理射击?

Any help is appreciated.任何帮助表示赞赏。

Not experienced in multiplayer development more than a beginner level, but here's my 2 cents.在多人游戏开发方面没有超过初学者水平的经验,但这是我的 2 美分。

You may be able to handle the bullet latency to some degree by following the advice in this tutorial.按照本教程中的建议,您可能能够在一定程度上处理子弹延迟。

https://unity3d.com/learn/tutorials/topics/multiplayer-networking/adding-multiplayer-shooting https://unity3d.com/learn/tutorials/topics/multiplayer-networking/adding-multiplayer-shooting

If you look at the script a bit down the page, they have a part that says.如果您在页面下方查看脚本,他们会有一部分说。

// This [Command] code is called on the Client …
// … but it is run on the Server!
[Command]
void CmdFire()

The library you use might have a similar method where it can be called on the client but run on the server.您使用的库可能有类似的方法,它可以在客户端调用但在服务器上运行。

Other than that, I'm a bit curious as to why you don't use the built-in unity multiplayer functionality?除此之外,我有点好奇你为什么不使用内置的统一多人游戏功能? It has both a low level and a high level API.它具有低级和高级 API。

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

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