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
560
UIElements 最高! 一番好きなUIフレームワークです!
noir_neo
0
590
24時間くらいで作ったゲーム 2019年
noir_neo
0
1.2k
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
110
FU2進捗141004
noir_neo
0
140
FU2進捗140920
noir_neo
0
120
Other Decks in Programming
See All in Programming
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism- An Example
philipschwarz
PRO
0
170
Hotwire or React? ~Reactの録画機能をHotwireに置き換えて得られた知見~ / hotwire_or_react
harunatsujita
9
4.1k
Why Spring Matters to Jakarta EE - and Vice Versa
ivargrimstad
0
1k
EventSourcingの理想と現実
wenas
6
2.1k
開発効率向上のためのリファクタリングの一歩目の選択肢 ~コード分割~ / JJUG CCC 2024 Fall
ryounasso
0
370
Vue.js学習の振り返り
hiro_xre
2
130
C#/.NETのこれまでのふりかえり
tomokusaba
1
160
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
350
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
160
Server Driven Compose With Firebase
skydoves
0
400
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
230
Importmapを使ったJavaScriptの 読み込みとブラウザアドオンの影響
swamp09
4
1.2k
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
51
13k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
328
21k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
Making the Leap to Tech Lead
cromwellryan
132
8.9k
Rails Girls Zürich Keynote
gr2m
93
13k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.2k
A designer walks into a library…
pauljervisheath
202
24k
Optimizing for Happiness
mojombo
376
69k
Gamification - CAS2011
davidbonilla
80
5k
Unsuck your backbone
ammeep
668
57k
Navigating Team Friction
lara
183
14k
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