SlideShare uma empresa Scribd logo
1 de 46
完全同期を実現する
TrueSync詳解 & UNET
互換Thunderなどご紹介
Photon運営事務局
TrueSync詳解
Photon運営事務局
並木 健太郎
アジェンダ
• TrueSync概要
• 機能紹介
• 使い方説明
TrueSync概要
New Service!
Photonの進化系!
何ができるの?
• 同期対象すべてのオブジェクトを
ラグを最小限に
完全同期
を実現
従来の物理の同期手法
• 従来の物理オブジェクトの同期手法
1. 座標で同期
• イベント時に座標を同期
– 齟齬は生じない
– メッセージ数が大きくなる
2. ベクトルを同期
• 自分自身の座標と移動量、方向を同期
– メッセージ数は少ない
– 物理エンジンに決定性がないため齟齬が生じる
決定性 -Deterministic-
• 同じ位置、大きさ、重さ、強さで演算すると
全て同じ結果になる
– 物理エンジンに決定性がある
• Unityの標準物理エンジンには決定性はない
– 環境、マシンスペック、タイミングなど
– 浮動小数点演算の誤差
– 人為的にキャップするのが一般的
決定性のなさ #1
• 簡単なデモを作りました
– 半径0.75、質量5の球が
100の速さで毎秒発射
– 半径1.5 高さ3、重さ50の円柱に衝突
– 床の大きさは32x32 摩擦係数は0.5
– 弾の跳ね返る方向、円柱が落ちる
までの時間等少しずつ齟齬が生じる
r = 1.5
h = 3
m = 50
r = 0.75
m = 5
v = 100
w = 32
h = 32
μ = 0.5
決定性のなさ #2
• よりわかりやすいデモ
– 半径0.75, 質量5の球が
100の速さで毎秒発射
– 一辺が1重さ1の立方体を
4x4x4個積み上げたものに衝突
– 床の大きさは32x32 摩擦係数は0.5
• 絶対に同じ結果にならない
=決定性はない
r = 0.75
m = 5
v = 100
w = 32
h = 32
μ = 0.5
h,w = 1
m = 1
4x4x4
完全同期を目指すと
• 極端な例 (座標)
– 4x4x4 = 64個のboxを同期
– 64(個) x 60(fps) x 4(ccu)
= 15360(msg/sec)
– ほぼ実現不可能
– ベクトルでやっても
齟齬が生じる
r = 0.75
m = 5
v = 100
w = 32
h = 32
μ = 0.5
h,w = 1
m = 1
4x4x4
TrueSyncの完全同期とは…?
• すべてのクライアントに
おいて、同期対象の全イ
ンスタンスが同一タイミ
ングで同様に動き、かつ
同一タイミングでイベン
トが発生する
どう実現…?
実現方法の考え方
基本
物理演算の結果を全クライアントで一致させる!
そのために
物理エンジンそのものが同期
そして
インスタンスへの入力をPhotonで通信
中身は?
• PUN
• 予測物理エンジン
• ロックステップシステム
PUN
• Unity向けに最適化されたPhotonのSDK
• TrueSyncでもベース部分はPUNを利用
• ゲーム内でも併用が可能
予測物理エンジン・キューシステム
• 予測物理エンジン
• ロックステップシステム
– は、この後の機能紹介で説明します
機能紹介
予測物理エンジン
• 決定性をもった物理エンジン
• 使用条件を満たせばあらゆるプラットフォーム
で同一の結果を導き出す
• 浮動小数点の代わりに固定小数点(FP)を利用
• 2D/3Dそれぞれを搭載
• Unityの標準物理エンジン互換で、リプレースが
容易
決定性・クロスプラットフォーム
• エンジンそのものはプラットフォーム依存なし
• 同一入力があればどのような環境下でも同一の
結果を出す
– 条件
• 浮動小数点を使わない
• ロックステップシステムを使う
浮動小数点・固定小数点
• 諸悪の根源である浮動小数点を排除
– タイミングやアーキテクチャで演算結果が異なる可
能性があるもの
• TrueSyncでは固定小数点を扱うFP型をすべての
物理演算にて導入
Unity標準エンジン互換
• Unity標準の物理エンジンからの移行が簡単にで
きるよう、コンポーネントを置き換えるだけで
利用可能
• シーンエディタでTrueSync対応のオブジェクト
を直接生成することも可能
Unity標準エンジン互換
クラス対照表
Unity TrueSync Unity TrueSync
BoxCollider TSBoxCollider PolygonCollider2D TSPolygonCollider2D
CapsuleCollider TSCapsuleCollider RidigBody TSRigidBody
CapsuleCollider TSCapsuleCollider SphereCollider TSSphereCollider
CircleCollider TSCircleCollider TerrainCollider TSTerrainCollider
Collistion TSCollision Transform TSTransform
ContactPoint TSContactPoint Vector TSVector
MeshCollider TSMeshCollider
ロックステップシステム
• ゲーム内の入力をキューイングするシステム
• Photonサーバーとの最大RTTをバッファリング
することにより、クライアント間でズレをなく
して同期が可能
• シンプルなので非常に簡単
• キューの内容を保存することにより、リプレイ
が簡単に実現可能
ロックステップシステム
入力
キューイング
アップデート
RTT連携バッファリング
Client A Client B
Server
Client C
50 ms 40 ms 80 ms
全体のバッファを80msに決定
ロックステップシステム全体
• 入力を一旦キューイングし、入力時刻と入力値
をキューイング
• キューイングされたデータを全クライアントに
共有
• バッファリング時間経過後、キューから取り出
しアップデートを実施
シーケンス図
Client A Client B Client C
入力
共有
共有
Update Update Update
遅延が大きくない…?
• 同期の完全性を担保するなら、遅延は仕方ない
• 完全性と低遅延を両立することはできないか?
– 入力を予測することによりバッファリング時間を小
さくすることが可能に
– 予測値が実際の入力と一致しなかった場合は、ロー
ルバックして再計算を実施
実際の利用方法
アセットダウンロード
• UnityのAsset Storeよ
り
Photon TrueSync
で検索
• できるだけ新規プロ
ジェクトから利用し
てください
ルーム参加まで
• ルームに入るまではPUNそのものです!
• 接続・マッチングは従来通り実装してください
• 次ページで説明するTrueSyncManagerを含む
シーンをロードすることにより、ロックステッ
プシステムが動作を開始
• Demoもご覧になってください
TrueSyncManager
• ロックステップシステムの要は
TrueSyncManager
です!
• TrueSyncを使うシーンには必ずこのプレハブを
置いておいてください
• Game Object/TrueSync/TrueSyncManagerで簡
単に導入できます
同期オブジェクト作成
• TrueSyncで基本的なプレハブを用意しています
– Cube
– Sphere
– Capsule
• 既存のプレハブを利用する場合は、Unityの物理
エンジンの代わりにTrueSyncの物理エンジンを
利用してください
入力受取
• 同期するプレハブにはTrueSyncBehaviourを基
底とするクラスを作成してコードを追加
• OnSyncedInput()メソッドで入力から値を受け取
る
• 値は必ずFP型(固定小数点)に変換
• キューに値を追加
入力受取例
public class PlayerInput : TrueSyncBehaviour {
public override void OnSyncedInput() {
FP accell = Input.GetAxis("Vertical");
FP steer = Input.GetAxis("Horizontal");
TrueSyncInput.SetFP(0, accell);
TrueSyncInput.SetFP(1, steer);
}
}
入力反映
• キューに有効な値があるタイミングで、
OnSyncedUpdate()メソッドが呼ばれる
• キューから値を取り出し、オブジェクトに適用
• 時間差もTrueSyncManager.DeltaTimeを利用
入力反映例
public override void OnSyncedUpdate() {
FP accell = TrueSyncInput.GetFP(0);
FP steer = TueSyncInput.GetFP(1);
accell *= 10 * TrueSyncManager.DeltaTime;
steer *= 250 * TrueSyncManager.DeltaTime;
tsTransform.Translate(0, 0, accell,
Space.Self);
tsTransform.Rotate(0, steer, 0);
}
インスタンス化
• TrueSyncManager.SyncedInstance()を利用
• 生成するタイミングはOnSyncedUpdate()で
物理のコールバック
• Unity標準のと同様にあります
– OnSyncedCollision{Enter|Stay|Exit}
– OnSyncedTrigger{Enter|Stay|Exit}
ドキュメント
• チュートリアルをぜひご覧ください
• https://doc.photonengine.com/ja-
jp/truesync/current/tutorial/tstutorial-part1-
download-install
使いどころ
• プレイヤー(クライアント)数が多いところには
今の所向きません
– 遅いクライアントがいると、全員がそこに引っ張ら
れるため
– 予測機能で補正可能だが、ロールバックの処理が多
く発生すると処理に時間がかかる可能性も
• まずは1v1などで検証を
まずはお試しを!
• Unity Asset Storeで無料ダウンロード可能で
す!
• クラウドサービスも20CCUまで無料!
• ぜひお試しください!
最後に
まとめ
• Photonは日々進化しています!
• 進化系であるTrueSyncをぜひお試しください!
• 新サービスにもご期待ください!
Thank you!
developer@photonengine.jp

Mais conteúdo relacionado

Destaque

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Destaque (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

【Photon勉強会】完全同期を実現するTrueSync詳解(2017/5/30講演)