I want to programmatically disable gravity in RealityKit without any help of Reality Composer.
let arView = ARView(frame: .zero)
let boxAnchor = try! Experience.loadBox()
arView.scene.anchors.append(boxAnchor)
How to do that?
I want to programmatically disable gravity in RealityKit without any help of Reality Composer.
let arView = ARView(frame: .zero)
let boxAnchor = try! Experience.loadBox()
arView.scene.anchors.append(boxAnchor)
How to do that?
You can disable model's gravity using components[PhysicsBodyComponent]:
let arView = ARView(frame: .zero)
let boxAnchor = try! Experience.loadBox()
let entity = boxAnchor.steelBox! as! (Entity & HasPhysics)
entity.components[PhysicsBodyComponent] = .none
arView.scene.anchors.append(boxAnchor)
Or using physicsBody instance property:
entity.physicsBody = .none