Draft
Conversation
tomoto
commented
Aug 21, 2024
Comment on lines
+70
to
+72
| // 重力が効くかを乱数で決める | ||
| let g = Bool.random() | ||
| bulletClone.physicsBody?.isAffectedByGravity = g |
Collaborator
Author
There was a problem hiding this comment.
重力が働くかどうかを乱数で決め、PhysicsBodyComponent の isAffectedByGravity プロパティを設定します。trueの場合は重力が働き、falseの場合は無重力となります。
tomoto
commented
Aug 21, 2024
Comment on lines
+73
to
+76
| // 重力が効くかによって色を変える | ||
| var material = PhysicallyBasedMaterial() | ||
| material.baseColor = .init(tint: g ? .green : .red, texture: nil) | ||
| bulletClone.model?.materials = [material] |
Collaborator
Author
There was a problem hiding this comment.
重力が働く場合は緑、働かない場合は赤になるように弾のマテリアルを設定します。これによりビジュアル的に挙動がわかりやすく、またいい感じにカラフルになります。
a9fa5e3 to
1fca32e
Compare
93934bf to
6632265
Compare
1fca32e to
a9fa5e3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
注: このDraft PRは「さらにステップアップ」の説明用です。実際にマージを要求するものではありません。
概要
Chapter 8の「シューティングゲーム改」の開発では、まずは弾に重力が働かず部屋の中を浮遊する版を作成し、次に重力を働かせて弾が床に落ちるようにしました。本ステップアップでは、重力の働く弾と働かない弾がランダムで混ざるようにし、空間コンピューティングならではの非現実的な体験を作り出してみます。
差分の確認とコードの修正
Files changedタブを開いて差分を確認し、アプリを修正してください。
ShootingLogic.swiftのshootメソッド内です。+で始まる行を追加、-で始まる行を削除してください。動作確認
修正後、Vision Pro実機またはシミュレータでアプリを実行してください。重力の働く緑の弾と重力の働かない赤い弾とがランダムで発射されます。
うまく動かないなど、答え合わせが必要な人はこのリンクから本修正適用済みのアーカイブをダウンロードし、
Chapter8フォルダを参照してください。解説
ソース差分上のコメントを参照してください。