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
570
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
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
270
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
840
命名をリントする
chiroruxx
1
420
ChatGPT とつくる PHP で OS 実装
memory1994
PRO
2
110
선언형 UI에서의 상태관리
l2hyunwoo
0
180
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
Spatial Rendering for Apple Vision Pro
warrenm
0
110
ドメインイベント増えすぎ問題
h0r15h0
2
350
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
GitHub's CSS Performance
jonrohan
1030
460k
RailsConf 2023
tenderlove
29
940
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Code Reviewing Like a Champion
maltzj
520
39k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Writing Fast Ruby
sferik
628
61k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
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