Unity3d_Multiplayer Netwoking8

Testing Multiplayer Movement

測試多人運動

To test Multiplayer movement we must again have two instances of the game running simultaneously.

為了測試多人游戲每瞒,我們必須再次同時運行兩個游戲?qū)嵗?/p>

The instance being run from the editor will be up-to-date with our changes, but the standalone build will be stale and needs to be updated with the most recent changes that we have made to the project.

從編輯器中運行的實例將與我們的更改同步喳瓣,但是獨立的構(gòu)建將會過時,需要更新我們對項目所做的最新更改土辩。

Build and Run this scene as a standalone application.

構(gòu)建并運行這個場景作為一個獨立的應用程序啼止。

The standalone player will now start and show the in-game UI from the NetworkManagerHUD.

獨立播放器現(xiàn)在將開始并顯示來自NetworkManagerHUD的游戲內(nèi)UI糯耍。

Click the LAN Host button from the in-game UI to start this game as a Host.

點擊游戲內(nèi)UI的局域網(wǎng)主機按鈕周霉,作為主機開始游戲。

We should see the game running with one player GameObject in the scene.

我們應該在場景中看到一個玩家在游戲中運行的游戲菩咨。

Return to Unity.

回到Unity。

Enter Play Mode

進入播放模式

The game will now run in the editor and show the in-game UI from the NetworkManagerHUD.

游戲?qū)⒃诰庉嬈髦羞\行陡厘,并從NetworkManagerHUD顯示游戲內(nèi)UI抽米。

Click the LAN Client button from the in-game UI to connect to the Host as a Client.

單擊游戲內(nèi)UI中的LAN客戶端按鈕以連接到主機作為客戶端。

There should be two player GameObjects;

應該有兩個玩家的游戲?qū)ο?

one for the local player on the Host and one for the remote player for this Client.

一個用于本地播放器糙置,另一個用于該客戶端的遠程播放器云茸。

Currently, they will be in the exact same position, so it may appear that there is only one player GameObject in the scene.

目前,他們將處于完全相同的位置谤饭,所以可能出現(xiàn)在場景中只有一個玩家的游戲?qū)ο蟆?/p>

By checking the Hierarchy Window, there should be two Player(clone)’s.

通過檢查層次結(jié)構(gòu)窗口标捺,應該有兩個播放器(克隆)。


To test moving the Client’s player GameObject in the scene:

在場景中測試客戶的播放器游戲?qū)ο?

Press the WASD or arrow keys to move and turn the Client's player

按下WASD或箭頭鍵移動并旋轉(zhuǎn)客戶端的播放器揉抵。

Note how the player GameObjects now move independently of each other.

注意玩家的游戲?qū)ο蟋F(xiàn)在是如何彼此獨立移動的亡容。

Switch back to the Stand Alone player.

切換回獨立球員。

To test moving the Host’s player GameObject in the scene:

測試在場景中移動主機的玩家游戲?qū)ο?

Press the WASD or arrow keys to move and turn the Host’s player.

按下WASD或箭頭鍵移動并旋轉(zhuǎn)主機的播放器冤今。

The two Player GameObjects should now be completely independent of each other and be in sync on both instances of the game.

這兩個游戲?qū)ο蟋F(xiàn)在應該是完全獨立的闺兢,并且在游戲的兩個實例上都是同步的。

When running two instances of the project, the remote player GameObject may not appear to be moving smoothly on the local client.

在運行項目的兩個實例時戏罢,遠程player GameObject可能不會在本地客戶機上順利地移動屋谭。

There may be a “steppy” feel to the movement of the remote Player's GameObject.

對于遠程玩家的游戲?qū)ο蟮囊苿樱赡軙幸环N“steppy”的感覺龟糕。

It is worth keeping in mind that all networked applications will be affected to some degree by latency and, more often, the limitations to the speed in which data can be moved moved between the Clients and Server.

值得記住的是桐磁,所有的網(wǎng)絡應用程序都會受到延遲的影響,而且更常見的是翩蘸,在客戶機和服務器之間移動數(shù)據(jù)的速度會受到限制所意。

There are many ways that latency and data transfers can be optimized.

有許多方法可以優(yōu)化延遲和數(shù)據(jù)傳輸。

For example, the NetworkTransform has a Network Send Rate setting which can be used to set how often the NetworkTransform sends synchronization data.

例如,NetworkTransform有一個網(wǎng)絡發(fā)送速率設置扶踊,可以用來設置網(wǎng)絡轉(zhuǎn)換發(fā)送同步數(shù)據(jù)的頻率泄鹏。

The frequency of updates over a network between Clients and Server can have a heavy impact on how a Networked Multiplayer game feels.

客戶端和服務器之間的網(wǎng)絡更新頻率對網(wǎng)絡多人游戲的感覺有很大的影響。


More importantly, however, there are many ways that a Networked application can cover for discrepancies in synchronization, whether these discrepancies are from sheer latency or due to the frequency of synchronizational updates.

然而秧耗,更重要的是备籽,網(wǎng)絡應用程序有許多方法可以彌補同步上的差異,這些差異是由于純粹的延遲分井,還是由于同步更新的頻率造成的车猬。

These solutions can include interpolation, extrapolation and many other forms of smoothing and prediction.

這些解決方案可以包括插值、外推和許多其他形式的平滑和預測尺锚。

None of these will be covered in this lesson.

這節(jié)課不會涉及這些內(nèi)容珠闰。

At this point, it is worth bearing in mind a few key points.

在這一點上,值得考慮幾個關鍵點瘫辩。

A balance will need to be struck between how often state synchronization happens and the performance of the game.

需要在狀態(tài)同步發(fā)生的頻率和游戲的性能之間找到平衡伏嗜。

If a game tries to synchronize too much data too often over a network, the performance of the game will suffer.

如果一個游戲試圖通過網(wǎng)絡同步過多的數(shù)據(jù),那么游戲的性能就會受到影響伐厌。

If a game does not synchronize data often enough, then the feel of the game and game-play could suffer.

如果一個游戲不經(jīng)常同步數(shù)據(jù)承绸,那么游戲和游戲的感覺就會受到影響。

In all cases there will need to be some form of interpretation of the synchronized GameObjects to keep all Clients feeling smooth and in sync while playing.

在所有的情況下挣轨,需要對同步的游戲?qū)ο筮M行某種形式的解釋军熏,以使所有的客戶在玩的時候感到平滑和同步。

All Multiplayer Networked games are never in perfect synchronization, as this is not physically possible.

所有的多人網(wǎng)絡游戲都不可能完全同步卷扮,因為這在物理上是不可能的荡澎。

Two or more remote Clients cannot be in the exact same state at the same time due simply to the time it takes to transfer the data between them.

兩個或多個遠程客戶端不能在同一時間處于完全相同的狀態(tài),原因是它們之間傳輸數(shù)據(jù)所需的時間画饥。

Games, however, need to feel as if they are in proper synchronization for the best player experience, even if the separate instances are slightly different in their exact state.

然而衔瓮,游戲需要感覺就好像它們是最佳玩家體驗的適當同步,即使個別的實例在它們的確切狀態(tài)稍有不同抖甘。

How to do this will be covered in detail in other lessons.

如何做到這一點热鞍,將在其他課程中詳細介紹。

Close the Stand Alone player.

關閉獨立球員。

Return to Unity.

回到Unity。

Exit Play Mode.

退出播放模式犬缨。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末糜工,一起剝皮案震驚了整個濱河市舒憾,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 212,454評論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件回梧,死亡現(xiàn)場離奇詭異废岂,居然都是意外死亡,警方通過查閱死者的電腦和手機狱意,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,553評論 3 385
  • 文/潘曉璐 我一進店門湖苞,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人详囤,你說我怎么就攤上這事财骨。” “怎么了藏姐?”我有些...
    開封第一講書人閱讀 157,921評論 0 348
  • 文/不壞的土叔 我叫張陵隆箩,是天一觀的道長。 經(jīng)常有香客問我羔杨,道長捌臊,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,648評論 1 284
  • 正文 為了忘掉前任问畅,我火速辦了婚禮娃属,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘护姆。我一直安慰自己,他們只是感情好掏击,可當我...
    茶點故事閱讀 65,770評論 6 386
  • 文/花漫 我一把揭開白布卵皂。 她就那樣靜靜地躺著,像睡著了一般砚亭。 火紅的嫁衣襯著肌膚如雪灯变。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,950評論 1 291
  • 那天捅膘,我揣著相機與錄音添祸,去河邊找鬼。 笑死寻仗,一個胖子當著我的面吹牛刃泌,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播署尤,決...
    沈念sama閱讀 39,090評論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼耙替,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了曹体?” 一聲冷哼從身側(cè)響起俗扇,我...
    開封第一講書人閱讀 37,817評論 0 268
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎箕别,沒想到半個月后铜幽,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體滞谢,經(jīng)...
    沈念sama閱讀 44,275評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,592評論 2 327
  • 正文 我和宋清朗相戀三年除抛,在試婚紗的時候發(fā)現(xiàn)自己被綠了狮杨。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 38,724評論 1 341
  • 序言:一個原本活蹦亂跳的男人離奇死亡镶殷,死狀恐怖禾酱,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情绘趋,我是刑警寧澤颤陶,帶...
    沈念sama閱讀 34,409評論 4 333
  • 正文 年R本政府宣布,位于F島的核電站陷遮,受9級特大地震影響滓走,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜帽馋,卻給世界環(huán)境...
    茶點故事閱讀 40,052評論 3 316
  • 文/蒙蒙 一搅方、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧绽族,春花似錦姨涡、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,815評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至检诗,卻和暖如春匈仗,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背逢慌。 一陣腳步聲響...
    開封第一講書人閱讀 32,043評論 1 266
  • 我被黑心中介騙來泰國打工悠轩, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人攻泼。 一個月前我還...
    沈念sama閱讀 46,503評論 2 361
  • 正文 我出身青樓火架,卻偏偏與公主長得像,于是被迫代替她去往敵國和親坠韩。 傳聞我的和親對象是個殘疾皇子距潘,可洞房花燭夜當晚...
    茶點故事閱讀 43,627評論 2 350

推薦閱讀更多精彩內(nèi)容