如何在实时多人游戏中移动对象? (统一的Google Play游戏插件) [英] how to Move Object in Real-time Multiplayer? ( Google Play Games plugin for unity)

查看:166
本文介绍了如何在实时多人游戏中移动对象? (统一的Google Play游戏插件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在统一创建一个实时多人游戏. 我正在使用此插件: https://github.com/playgameservices/play- Games-plugin-forunity

i'm creating a realtime multiplayer game in unity. i'm using this plugin : https://github.com/playgameservices/play-games-plugin-for-unity

我需要在场地(地面)中移动一个球.

i need to move a ball in field(ground).

我可以在两个播放器之间发送和接收消息.但我不知道应该发送哪些信息以及何时发送. 例如,我正在发送myObject.transform.position;

i can send and receive message between two player. but i don't know which information should i send and when to send. for example i'm sending myObject.transform.position;

您能给我一些关于同步球在场上移动的想法吗?

can you give me some ideas about syncing the ball's move in field?

推荐答案

您可以尝试发送目标排名.然后,当您收到此目标位置时,可以尝试从当前位置插值到目标位置.这将使运动更加平稳,并且对网络的依赖性降低.同样,如果您的球完全基于物理原理,则必须传递速度和加速度.但是每隔几帧左右,您需要检查一下位置是否与另一个屏幕相距太远,并且可能需要将其捕捉回去. 对于更复杂和动态变化的运动,您必须进行一些预测.

You can try sending the target position instead. Then when you receive this target position, you can try to interpolate from the current position to the target position. This will make the movement more smooth and less dependent on the network. Similarly, if your ball is fully based on physics you have to send velocity and acceleration over. But every few frames or so, you need to check if the position is too far away from the other screen and you may need to snap it back. For even more complex and dynamically changing motions, you have to do some prediction.

这篇关于如何在实时多人游戏中移动对象? (统一的Google Play游戏插件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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