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
600
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
Macとオーディオ再生 2024/11/02
yusukeito
0
370
Jakarta EE meets AI
ivargrimstad
0
190
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
130
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
880
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.1k
Jakarta EE meets AI
ivargrimstad
0
570
CSC509 Lecture 13
javiergs
PRO
0
110
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
297
20k
Practical Orchestrator
shlominoach
186
10k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Bash Introduction
62gerente
608
210k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Unsuck your backbone
ammeep
668
57k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Producing Creativity
orderedlist
PRO
341
39k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
The Invisible Side of Design
smashingmag
298
50k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
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