Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
24時間でゲームをつくるための Unity
Search
ねおりん
April 04, 2019
Programming
2
1.8k
24時間でゲームをつくるための Unity
https://cluster-vr-meetup.connpass.com/event/124095
ねおりん
April 04, 2019
Tweet
Share
More Decks by ねおりん
See All by ねおりん
アバターミーティングを支える技術
noir_neo
0
580
UIElements 最高! 一番好きなUIフレームワークです!
noir_neo
0
600
24時間くらいで作ったゲーム 2019年
noir_neo
0
1.3k
Multiuser AR Experience を ARKit + Unity で実装する
noir_neo
0
2.6k
これで安心! hubot 沼の堕ち方〜娘がいると開発が楽しいね!
noir_neo
0
340
MDLT#004
noir_neo
0
1.5k
FU2 展示反省
noir_neo
0
120
FU2進捗141004
noir_neo
0
140
FU2進捗140920
noir_neo
0
130
Other Decks in Programming
See All in Programming
rails newと同時に型を書く
aki19035vc
5
710
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
0
150
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
240
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
420
AppRouterを用いた大規模サービス開発におけるディレクトリ構成の変遷と問題点
eiganken
1
440
HTML/CSS超絶浅い説明
yuki0329
0
190
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
1.9k
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
400
為你自己學 Python
eddie
0
520
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
1.3k
混沌とした例外処理とエラー監視に秩序をもたらす
morihirok
13
2.3k
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
120
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.5k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Rails Girls Zürich Keynote
gr2m
94
13k
The Invisible Side of Design
smashingmag
299
50k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Navigating Team Friction
lara
183
15k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Scaling GitHub
holman
459
140k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
How GitHub (no longer) Works
holman
312
140k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
Transcript
24࣌ؒͰήʔϜΛͭ͘ΔͨΊ ͷ Unity 2019/4/4 cluster.unity #1 Ͷ͓ΓΜ (@noir_neo) 1
Ͷ͓ΓΜ • @noir_neo • ήʔϜΛͭ͘Δ • Ϋϥελʔגࣜձࣾ • ιϑτΣΞΤϯδχΞ •
όʔνϟϧϋτ(Ծ) 2
ਪ͠ͷVλϨϯτ 3
somunia • @she_is_wired • youtube.com/c/somuniaroom 4
24࣌ؒͰήʔϜΛͭ͘ΔͨΊ ͷ Unity ֓ཁ • 24࣌ؒͰήʔϜ࡞Δͭ • ݟͳͲ • ·ͱΊ
5
24࣌ؒͰήʔϜ࡞Δͭ • 24࣌ؒ(͘Β͍)ͰήʔϜ࡞Δ • Unity1िؒήʔϜδϟϜΛΖ͏ͱ͚ͯͨ͠Ͳɺ1ि͍ؒ ͳͬͯ͜ͱͰ࢝Ίͨ • ༑ୡͱ͔ಉ྅ͱͬͯΔશʹݸਓతͳ࠵͠ • ࣮ࡍʹίʔυॻ͍ͯΔͷ12࣌ؒఔ
• ͰΞσΟγϣφϧλΠϜΓ͕ͪ 6
24࣌ؒͰήʔϜ࡞Δͭ • ڈ10ճͬͨ ࠓ2ճ • Ұ൪ଟͬͯ͘Δߏ ΤϯδχΞ2 σβΠφʔ1 • جຊతʹՌ
WebGL Ϗϧυ 7
࠷ۙͷՌΛհ͠·͢ • େסഋ THE GREAT KANPAI • POPPO SHOOTER 2019
• RUN • sun-ma 8
9
10
11
12
13
14
ݟͳͲ • 24࣌ؒͰͤ͞ΔͨΊʹɺࢲୡ͕͍Ζ͍Ζࢼͯ͠ࠓͷॴͨͲ Γண͍ͯΔΞϨίϨ • ڠۀ͢Δʹ͋ͨͬͯͳΔ͓͘ޓ͍ͷ࡞ۀΛϒϩοΫ͠ͳ͍ • ͋ΔఔϝϯςφϏϦςΟࣺͯͯΛऔΔ • ͔͋͠͠·Γʹແடংͩͱ͠ͳ͍!
15
ݟͳͲ • ͜͜Ͱൃද͢Δ͜ͱϓϩμΫγϣϯίʔυͰ௨༻͠·ͤΜ • ήʔϜδϟϜͱ͔ϓϩτλΠϐϯάͷώϯτʹͳΕ͍ • Ͱ͖Δ͚ͩଟ͘ͷ tips Λհ͢ΔͨΊʹͻͱͭͻͱͭৄ͍͠આ ໌͠·ͤΜ
• ؾʹͳͬͨ͜ͱɺΑ͘Θ͔Βͳ͔ͬͨ͜ͱͳͲ͋ͱͰฉ͍ ͍ͯͩ͘͞! 16
ݟͳͲϦετ 1/2 • ઃܭࡶʹΔ • 1scene ͰλΠτϧʙϦβϧτ·ͰΔ • Zenject ϛχϚϜʹ͏
• UniRx ࠷ݶ class ؒͷΠϕϯτ௨Ͱ͏ • Input interface Ͱ͍͍ײ͡ʹ 17
ݟͳͲϦετ 2/2 • nested prefab ਆ • CPU ͷ࣮ Random
Ͱे • UniRx.Async ήʔϜશମͷεςʔτཧʹศར • Cloud Build ΘΓͱΦεεϝ • deploy ࣗಈԽ͓ͯ͜͠͏ 18
ઃܭࡶʹΔ • શମͷߏ֬ೝͱ୲ͷՄࢹԽͷͨΊʹ͢Δ • namespace ͱ class ͱґଘͷ͖͘Β͍ • property
ͱ͔શ෦ॻ͜͏ͱ͠ͳ͍ 19
20
21
1scene ͰλΠτϧʙϦβϧ τ·ͰΔ • ͦΜͳʹϦονͳλΠτϧ/ϦβϧτΛ࡞͍ͬͯΔՋͳ͍ • scene ભҠͱ͔ॻ͘͘Β͍ͳΒ UI ͷ
active Γସ͑Δ͚ͩͰ͍ ͍! • ੩తͰ͍͍ͷͱʹ͔͘ scene ʹ͓͍͍ͯ͘ • ίϯϑϦΫτ͢ΔͱࠈͳͷͰ prefab ʹ͢Δͷඞਢ!! 22
23
Zenject ϛχϚϜʹ͏ Zenject ͕ԿͰ͋Δ͔Έͳ͞ΜͬͯΔମͰߦ͖·͢ 24
Zenject Binding (ͱ Zen Auto Injecter) ੵۃతʹ͍ͬͯ͘ • scene ͷϧʔτΦϒδΣΫτಉ࢜ͷґଘ
SerializeField Ͱղܾ ͠ͳ͍΄͏͕ྑ͍ • γʔϯʹอଘ͞ΕΔͷͰίϯϑϦΫτϦεΫ͕ߴ͍ • Factory ॻ͘ྔ͕૿͑Δ͚ͩͰࢫΈ͕গͳ͍ • ࣮ߦίετؾʹ͍͚ͯ͠ͳ͍ 25
GameObjectContext player Λಈత ʹ࡞Δͱ͖ͳͲʹ༗ޮ͕ͩ… • ී௨ʹ Instantiate ͨ͠΄͏͕ૣ͍ •
input ͷࠩ͠ସ͑ΛͲ͏Δ͔͍͠ͱ͜Ζ • ཧ pure class ͰΓ͍͕ͨ GameObject Context Installer ʹ Ҿ͢ͷͱ͔ΊΜͲ͍͘͞ • Monobehaviour ʹͯ͠ GetComponent<IInputEventProvider>(); ͰेΆ͍ 26
UniRx ࠷ݶ class ؒͷΠ ϕϯτ௨Ͱ͏ UniRx ͕ԿͰ͋Δ͔Έͳ͞ΜͬͯΔମͰߦ͖·͢ 27
ґଘੑٯస͠Α͏ • interface Λաʹͬͯɺ24࣌ؒʹ͏Ε͍͜͠ͱͦΜͳ ʹͳ͍ • ݫີʹґଘੑٯసΛ͢Δඞཁͳ͍͕… • நʹґଘͤ͞ͳ͍ͱͯ͠ Observer
ύλʔϯͰґଘͷ͖ ٯʹ͓ͯ͘͠ • class ͷ͕͚͘͢ɺػೳՃ͕͍͢͠ɺίϯϑϦΫ τϦεΫԼ͕Δ 28
كʹΑ͘ݟΔίʔυ 29
public class PlayerCore : MonoBehaviour { [Inject] IInputEventProvider inputEventProvider; bool
CanJump { get; set; } // ໘ʹ͍͍ͭͯΔ͔ͱ͔ void Start() { inputEventProvider.Jump .Where(b => b && CanJump) .Subscribe(_ => Jump()) .AddTo(this); } 30
[SerializeField] PlayerMover mover; void Jump() { mover.Jump(); } } 31
δϟϯϓͨ͠ͱ͖ʹΞχϝʔγϣϯ Λͭͭ͠SE໐Β͍ͨ͠! 32
[SerializeField] PlayerMover mover; + [SerializeField] PlayerAnimator animator; + [SerializeField] SeEmitter
seEmitter; void Jump() { mover.Jump(); + animator.Jump(); + seEmitter.Jump(); } } 33
Γ͍ͨ͜ͱ͕૿͑Δͨͼʹ PlayerCore ʹॲཧ͕૿͍͑ͯ͘ 34
35
public class PlayerCore : MonoBehaviour { [Inject] IInputEventProvider inputEventProvider; bool
CanJump { get; set; } // ໘ʹ͍͍ͭͯΔ͔ͱ͔ public IObservable<Unit> OnJump => inputEventProvider.Jump .Where(b => b && CanJump) .AsUnitObservable(); } 36
public class PlayerMover : MonoBehaviour { [SerializeField] PlayerCore core; [SerializeField]
Rigidbody rb; void Start() { core.OnJump .ObserveOn(Scheduler.MainThreadFixedUpdate) .Subscribe(_ => rb.AddForce(0, jumpPower, 0, ForceMode.Impulse)) .AddTo(this); } } 37
public class PlayerAnimator : MonoBehaviour { [SerializeField] PlayerCore core; [SerializeField]
Animator animator; void Start() { core.OnJump .Subscribe(_ => animator.SetTrigger("Jump")) .AddTo(this); } } 38
39
Input interface Ͱ͍ ͍ײ͡ʹ 40
interface IInputEventProvider { IReadOnlyReactiveProperty<float> Move { get; } } 41
public class PlayerCore : MonoBehaviour { void Start() { var
input = GetComponent<IInputEventProvider>(); } } 42
public class PlayerInput : MonoBehaviour, IInputEventProvider { readonly ReactiveProperty<float> move
= new ReactiveProperty<float>(); IReadOnlyReactiveProperty<float> IInputEventProvider.Move => move; void Update() { move.Value = Input.GetAxis("Horizontal"); } } 43
public class CpuInput : MonoBehaviour, IInputEventProvider { readonly ReactiveProperty<float> move
= new ReactiveProperty<float>(); IReadOnlyReactiveProperty<float> IInputEventProvider.Move => move; void Update() { move.Value = Random.insideUnitCircle.x; } } 44
nested prefab ਆ • Ϟσϧͷࠩ͠ସ͕͑ඵͰऴΘΔ • 2PΧϥʔͱ͔ɺίʔυͰϚςϦΞϧม͑ΔΑΓѹతʹָ 45
• ϞσϧʹجૅతͳεΫϦϓτ͚ͩ͠ ͨͷΛ variant • 1PΧϥʔͷϚςϦΞϧઃఆͨ͠ͷ Λ variant' • 2PΧϥʔͷϚςϦΞϧઃఆͨ͠ͷ
Λ variant'' • ͜Ε2PΑΓ૿͑ͳ͍લఏͩͬͨ ͷͰ 46
CPU ͷ࣮ Random Ͱे 47
దʹ Update loop ʹ Random Ͱॻ ͍͓͚ͯͱΓ͋͑ͣͦΕͬΆ͘ͳΔ • value ͱ͔
Range ͚ͩͰͳ͘ɺ insideUnitCircle Λ͏ͱ͔ • ݅ʹԠͯ֬͡Λม͑ͨΓ 48
ʰେסഋʱͷ CPU ϓϨΠ ϠʔͷҐஔ͢ΒΒͳ͍ 1. ҰఆҎ্ʹ͍Δͱδϟϯϓ͢Δ্͕֬Δ 2. తਅΜதΛબͼ͘͢ • insideUnitCircle.x
Λ͍ͬͯΔ 3. తʹ͍ۙͮͨΒҰఆ֬Ͱ࣍ͷతΛܾΊΔ 49
UniRx.Async ήʔϜશମͷ εςʔτཧʹศར • λΠτϧը໘ͰʰελʔτʱϘλϯ͕ԡ͞ΕͨΒήʔϜ͕͡ ·ͬͯɺࢮΜͩΒϦβϧτΛදࣔ͢Δ • ॲཧҰຊಓ • async/await
Ͱॻ͘ͱ͍͍ײ͡ 50
async void Start() { await Title(); await StartGame(); await GameOver();
await Result(); } async UniTask Title() { titleUi.Show(); await titleUi.OnStartClickAsObservable.ToUniTask(); } 51
Cloud Build ΘΓͱΦεε ϝ • ݶΒΕͨ࣌ؒͱϚγϯϦιʔεͷதͰɺϏϧυʹୣΘΕΔͷ ͍ͬͨͳ͍ • ͱʹ͔͘Ϗϧυճ͓͔ͯ͠ͳ͍ͱɺஃͰʮΤσΟλͰ ಈ͘ͷʹϏϧυͰಈ͔ͳ͍!!ʯ͕ى͖͕ͪ(Կճ͔ͬͯΔ)
52
ͱΓ͋͑ͣ $9/month ͓͚ͬͯ • ࠷ۙΘΓͱ·ͱʹͳͬͨ • ͪΌΜͱ࠷৽ͷόʔδϣϯ͕͑Δ͠ • WebGL ͷ
custom template Θͤͯ΄͍͠ 53
͍ͨ͘ͳ͍ਓ • Ҏલࢲ͕͍ͬͯͨࣗಈϏϧυͷεΫϦϓτΛ͓͍͍ͩ͘͞ • git worktree Ͱ৽͍͠ϫʔΫεϖʔεΛ࡞ͬͯϏϧυͯ͠ gh- pages ϒϥϯνʹ
push ͢Δ • ϚγϯϦιʔε͏͚ͲɺϏϧυதʹ࡞ۀετοϓ͠ͳ͍ https:/ /github.com/noir-neo/unity-webgl-ghpages/blob/master/ build.sh 54
deploy ࣗಈԽ͓ͯ͜͠͏ • static ͳϦϯΫ͕΄͍͠ • ࠷ऴՌΛެ։͓ͯ͘͠ͷʹɺ github pages ૬ੑ͕͍͍
• zip ΛσϓϩΠ͢Δ shell • ͱʹ͔͘ऴΘΓࠒόλόλ͢ΔͷͰɺࣗಈԽͰ͖Δ෦ ͓ͯ͘͠ https:/ /gist.github.com/noir-neo/ 3a2071dc6d8ea8300caed4bc2bb2de26 55
24࣌ؒͰήʔϜ࡞Δͭએ • աڈͷ࡞ूͯͳϒϩάʹ • http:/ /noir-neo.hatenablog.com • ιʔεͯ͢ github ʹ
• https:/ /github.com/one-night-game-jam • ຖճ twitch Ͱ৴ͯ͠Δ • https:/ /www.twitch.tv/noirneo 56
·ͱΊ • ࣌ؒͰήʔϜΛͤ͞ΔͨΊͷ tips ूΛհ͠·ͨ͠ • جຊతͳઃܭͷߟ͑ํͱɺͦͷ࣮ྫɺ͋ͱϏϧυ Έ͍ͨͳ Ͱͨ͠ •
ήʔϜδϟϜͱ͔ϓϩτλΠϐϯά͢Δͱ͖ͷώϯτʹͳΕ ͍Ͱ͢ 57