We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a9fa5e3 commit 93934bfCopy full SHA for 93934bf
Chapter8/Chapter8/ShootingLogic.swift
@@ -67,6 +67,13 @@ class ShootingLogic: ObservableObject {
67
let bulletClone = bullet.clone(recursive: true)
68
bulletClone.position = position
69
bulletClone.physicsMotion?.linearVelocity = velocity
70
+ // 重力が効くかを乱数で決める
71
+ let g = Bool.random()
72
+ bulletClone.physicsBody?.isAffectedByGravity = g
73
+ // 重力が効くかによって色を変える
74
+ var material = PhysicallyBasedMaterial()
75
+ material.baseColor = .init(tint: g ? .green : .red, texture: nil)
76
+ bulletClone.model?.materials = [material]
77
bulletRoot.addChild(bulletClone)
78
// アクションのコールバック
79
shootAction()
0 commit comments