見出し画像

中級編1:ARDKでマルチプレイゲームをつくってみよう! #1

1. Introduction -  はじめに

Hi! My name is Alexson Chu from the Designium. I'm a Multimedia Creator from Hong Kong. I've been in the interactive field for over 10 years, working for AR, VR, MR, interactive games etc. Recently joined Designium.

こんにちは!デザイニウムAlexson Chuです。 私は香港在住のマルチメディアクリエイターです。 インタラクティブ分野に10年以上携わっており、AR・VR・MR・インタラクティブゲームなどを制作しています。最近デザイニウムにジョインしました。
【Niantic Lihtship ARDKをつかってみよう!】
第一回: 初級編1: ARDKってなに?
第二回: 初級編2: ARDKで簡単なアプリをつくってみよう!
第三回: 中級編1: ARDKでマルチプレイゲームをつくってみよう! #1 ※本記事
第四回: 中級編2: ARDKでマルチプレイゲームをつくってみよう#2
第五回: 中級編3: ARDKでマルチプレイゲームをつくってみよう#3(後日公開)
第六回: 中級編4: ARDKでマルチプレイゲームをつくってみよう#4(後日公開)

In this tutorial, I will show you how to create a basic multiplayer game with an ARDK example, from the Game start, share player data, spawn object data, to game end.

中級編では、ARDKのサンプルを使って、ゲームの開始合図、プレーヤーデータの共有、オブジェクトデータの生成からゲームの終了合図、のようなデータを通信するシンプルなマルチプレイヤーゲームを作成する方法を解説します。
この記事では、マルチプレイヤーゲームを実現するための通信周りの基礎知識を解説しています。

2. Game to be made this time - 今回作るゲーム

For this time, we will create a simple first-person shooting style bombing game.
Game Play is as simple as this, Player(s) place bombs on the ground and try to damage others until their HP is zero within a certain game time.
We will take a provided game example and turn it into a multiplayer version.
(note: If this is your first time creating a multiplayer game, the gameplay better be as simple as possible.)

今回は、シンプルな一人称シューティングスタイルの爆撃ゲームを作成します。
ゲームのルールはとても簡単です。プレイヤーは爆弾を地面に置き、特定のゲーム時間内にHPがゼロになるまで他のプレイヤーにダメージを与え続けていくというものです。このルールのゲームをマルチプレイヤーバージョン対応させていきます。
(注:マルチプレイヤーゲームを作成するのが初めての場合は、ゲームプレイをできるだけシンプルにすることをオススメします。)

3. Basic knowledge of multiplayer games - マルチプレイヤーゲームの基礎知識

There are different ways of multiplayer, for this time. We are going to make a Host-Client type of multiplayer this time.

ゲームのロジックを実装する前に、マルチプレイヤーのための通信の基礎を解説します。

マルチプレイヤーを実現するには様々な方法がありますが、今回はHost-Clientタイプの通信方法を使ったものをつくっていきます。

画像1

Imagine you are hosting a party with guests in real life, you will need to invite everyone to your “room” in order to play it together.
Multiplayer games work in a similar way. There will be a “Host”, create a “Room”(Session) with “Room Number”(Session ID).
After that, you (the host) will ask your guests to enter the exact “Room” by the “Room Number” you provided. Therefore they can be played in the same room now.

あなたが現実世界で招待客を呼んでパーティーを主催しているところを想像してみてください。一緒に楽しむためには、お客さん全員にパーティ会場の住所が記載された招待状を送る必要があります。

マルチプレイヤーゲームでの考え方も同じです。「Host」という主催が、「Room Number」(セッションID)で「Room」(セッション)、つまり会場を作成します。
次に、Host(ホスト)であるあなたは、お客さんに「Room Number」を提供します。そして、お客さんに正確な「Room Number」を入力してもらいます。その結果、あなたとお客さんが、同じ「Room」で遊ぶことができるようになります。

画像2

Moreover, you will need to tell people in the room when the game started and ended. And everyone should also tell each other about their current status like HP, ID...etc

Traditionally, it would be a lot of work to prepare before building the actual game, luckily for us, all these things can be handled easily using ARDK.

「Room」作って招待するだけでは、ゲームを実現できません。
Host(ホスト)であるあなたは、ゲームの開始時と終了時の合図を全員に通信する(伝える)必要があります。 また、HP、IDなどの現在のステータスについては、全員がお互いに通信する必要があります。

これまでは、通信するゲームを作成するための準備は大変な作業でしたが、幸いなことに、これらはすべてARDKを使用して簡単に実現できます

3-1. Glossary - 用語解説

Multiplayer Session

画像3

Session – Session is the “Room” created by the Host. It is the “Room” for other players to join in.
Host – The session creator. And can be identified “IsHost'' in most of the ARDK objects
Self – Useful to identify whichever the spawn object or player object is created by myself
Peer – All the connected players including host and client
Message – Data to be send and receive

Please see here to see more detailed information:
https://lightship.dev/docs/multiplayer_experience.html

Multiplayer Session - マルチプレイヤーセッション
Session
– Hostによって作成された「Room」。 他のプレイヤーが参加できる「Room」です。
Host
–セッションの作成者。 ほとんどのARDKオブジェクトは「IsHost」でHostかどうかを判断できます。
Self
– 自分自身が作成したプレイヤーオブジェクトまたはその他のオブジェクト
Peer – 接続されたプレイヤー
Message – 送受信するデータ

詳細については、公式ドキュメントをご覧ください。
https://lightship.dev/docs/multiplayer_experience.html

Shared AR Experience
Besides basic network sessions, we will also need to know the exact position of other players, therefore we can interact with players in AR accordingly. This localization action is communicated and synchronized by an “Environment Map”

AR空間情報の共有
基本的なネットワーク通信に加えて、他プレイヤーの正確な位置も知る必要があるため、同じAR空間のプレイヤー同士で通信することができます。 このローカリゼーションアクションは、「環境マップ」によって、通信および同期されます。

画像4

Map – A map generated by the Host device for the client to be synchronized
PeerPoses – A transform data from each peer, representing the peer relative position in the AR World.

You can see more detail of the concept of localization:
https://lightship.dev/docs/establishing_localization.html

Map - Peer同士が同期するための空間情報。Hostによって生成されます。
Peer Poses - Peerの座標。AR空間でのPeerの相対位置を表します。

ローカリゼーションの概念の詳細は、公式ドキュメントをご覧ください
https://lightship.dev/docs/establishing_localization.html

3-2. Communication data - 通信データ

With the ARDK’s Example, some of the elements have been already taken care of. However, we still need to share some data for our gameplay. Let’s break down the game elements required for this game.
The table below shows whether each of the data transmissions is already implemented or whether additional implementation is required.

ARDKのサンプルプロジェクトでは、いくつかの通信が実装されています。 今回作成するゲームを実現するには、いくつかのデータ通信を追加実装する必要があります。
それぞれのデータ通信が実装済みか、それとも追加実装が必要かを下記の表にまとめました。

Please keep this in mind as you implement it, as it will be explained.

実際に実装していくときに、解説しますので頭の片隅に置いておいてください。

In the best-case scenario, we should share all the data with everyone instantly for the best experience. However, it’s always a good practice to choose how many and how often we send and receive the messages. Like Game Start and Game Ended, we will only need to notify all peers once, but with position data, we may want to sync more often.

Please see here to see more detailed information:
https://lightship.dev/docs/low_level_networking_gotchas.html

通信頻度についてですが、ベストシナリオでは、最高のエクスペリエンスを実現するために、すべてのデータを即座に全員に共有する必要があります。 ただし、メッセージを送受信する回数と頻度を常に調整する必要があります。 GameStartやGameEndedと同様に、すべてのピアに1回だけ通知する必要がありますが、位置データについてはもっと頻繁に同期する必要があります。

詳細については、公式ドキュメントをご覧ください。
https://lightship.dev/docs/low_level_networking_gotchas.html

Next, we will start to create the basic game from the ARDK example!

次の記事では、ARDKのサンプルプロジェクトからゲームを実際に作成していきます!

4. Editorial Note- 編集後記

こんにちは!デザイニウム広報のマリコです。最近joinしたAlexsonによる初記事はいかがでしたか?✨香港在住ということで彼のR&D動画の背景も楽しんだりしています😊さて、2021年もまもなく終わりですね。デザイニウムのnoteは今年ついに10万viewを突破しました🎉読んでくださっているみなさん、ありがとうございます❗そして編集後記まで読んでくださっているみなさま、本当にありがとうございます!🙏 次回記事は、新年を迎えてからなるべく早く公開しますのでお楽しみに😉それでは、みなさま良いお年を✨🎍

新年を迎えた2022年1月13日に、ARDK Meetup vol.1を開催します🎉
まだARDKを使っていない方も、がっつり使っている方も、この記事を読んでくれている方はぜひお気軽にご参加ください❗


The Designium
Official website
Interactive website
Twitter (フォローお待ちしてます✨)
Facebook



この記事が気に入ったらサポートをしてみませんか?