多人台球游戏物理模拟 [英] Multiplayer billiards game physics simulation

查看:159
本文介绍了多人台球游戏物理模拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建在线多人台球游戏,我正在努力思考最佳的多人物理模拟方法.我考虑了三种可能的情况,每种情况都有其优点和缺点,我想听听那些已经实施了类似功能或具有多人在线游戏经验的人的意见.

I’m building an online multiplayer billiards game and I’m struggling to think of the best approach to multiplayer physics simulation. I have thought of a three possible scenarios, each having its own advantages and disadvantages and I would like to hear some opinion of those that either have implemented something similar already or have experience in multiplayer online games.

第一种情况:在客户端上进行物理模拟:玩家进行射击,将射击的角度和力量发送到服务器,服务器将使用这些值更新所有客户端,以便他们可以独立模拟镜头.

1st Scenario: Physics simulation on the clients: The player in turn to take a shot sends the angle of the shot and power to the server, and the sever updates all clients with these values so they can simulate the shot independently.

优势:

  1. 服务器过热

缺点:

  1. 同步问题.客户必须模拟精确的模拟,而不管其帧频如何. (可能可以通过一些巧妙的算法来解决,例如此处)
  2. ) >
  3. 作弊.玩家可以通过调整物理引擎来作弊. (可以确定在射门结束时何时与其他球员的球位置进行比较.如果只有两名球员在桌子上(即不是壮观),那么作弊者是谁?)

第二种情况:

在一个(即主")客户(例如拍摄镜头的人)上进行物理模拟,然后将每个物理步骤广播给其他人.

Physics simulation on one (i.e. "master") client (e.g. who ever takes the shot) and then broadcast each physics step to everyone else.

优势:

  1. 同步没有问题.

缺点:

1.服务器过热.每隔一段时间,主"客户端将把所有球的坐标发送到服务器,服务器将不得不将它们广播给房间中的其他所有人. 2.仍然可以由主"玩家作弊.

1.Server overheat. Each time step the "master" client will be sending the coordinates of all balls to the server, and the server will have to broadcast them to everyone else in the room. 2. Cheating by the "master" player is still possible.

第三种情况:物理将在服务器上模拟.

3rd Scenario: The physics will be simulated on the server.

优势:

  1. 由于模拟是独立于客户端运行的,因此无法作弊.
  2. 没有同步问题,一次模拟意味着每个人都会看到相同的结果(如果由于网络延迟而无法同时显示事件)

缺点:

  1. 巨大的服务器过载.服务器不仅必须每秒为每张桌子(可能同时有100张桌子)每秒计算30/60次物理量,而且还必须将所有坐标广播给房间中的每个人.

编辑 与我制作的游戏类似的游戏,以防有人熟悉如何克服这些问题:

EDIT Some of similar games to the one I’m making, in case someone is familiar with how they have overcame these issues:

http://apps.facebook.com/flash-pool/
http://www.thesnookerclub.com/download.php
http://gamezer.com/billiards/

推荐答案

我认为第三个是最好的.

I think that the 3rd one is the best.

但是如果在将它们发送给客户端之前计算服务器中的所有碰撞和运动(每次碰撞和运动等),则可以使客户端变得更好,那么客户端只需要执行"它们即可.

But you can make it even better if you compute all the collisions and movement in the server before sending them to the clients (every collisions and movements, etc...) then clients just have to "execute" them.

如果这样做,您每次发送信息只会发送一次,这将大大减少网络问题.

If you do that you will send the informations only once per shot, that will greatly reduce the network issue.

就像JimR所写的那样,您应该使用速度或运动方程,而不是一步一步地进行逐步仿真(例如Runge-Kutta方法)

And as JimR wrote, you should use velocity or movement equation instead of doing small step by small step incremental simulation (like the Runge-Kutta method)

服务器发送给客户端的信息如下:

The information that the server send to the client would look like this:

Blackball hit->move from x1,y1 to x2,y2 until time t1
Collision between blackball and ball 6 at time t1
Ball 6 -> move from x3,y3 to x4,y4 until time t3
Blackball -> move from x5,y5 to x6,y6 until time t4
Collision between Ball 6 and Ball 4 at time t3
and so on until nothings move anymore

此外,您可能需要一堆代表不同物理方程的类,并有一种方法可以将它们序列化以将其发送给客户端(Java或C#可以轻松地序列化对象).

Also, you are likely to need a bunch of classes representing the differents physics equations and have a way to serialize them to send them to the clients (Java or C# can serialize objects easily).

这篇关于多人台球游戏物理模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆