How to add Linear and Angular motion to an Entity? I am trying by this:
func makeUIView(context: Context) -> ARView {
let arVIew = ARView(frame: .zero)
context.coordinator.arVIew = arVIew
arVIew.session.delegate = context.coordinator
let config = ARWorldTrackingConfiguration()
arVIew.session.run(config, options: [.resetTracking,.removeExistingAnchors])
let anchorEntity = AnchorEntity()
loadASingleModel(name:"toy_biplane") { entity in
if let entity = entity {
// let physics = Physics()
let kinematics: PhysicsBodyComponent = .init(massProperties: .default,
material: nil,
mode: .kinematic)
let motion: PhysicsMotionComponent = .init(linearVelocity: [0.1 ,0, 0],
angularVelocity: [3, 3, 3])
entity.components.set(kinematics)
entity.components.set(motion)
entity.physicsBody?.mode = .kinematic
anchorEntity.addChild(entity)
//anchorEntity.transform.matrix.columns.3.z = -1.0
arVIew.scene.anchors.append(anchorEntity)
print("Model Added: ",entity.name)
}else{
print("No entity avaible")
}
}
return arVIew
}
But My code is not working. The Loaded entity does not move. How Can I add motion to the loaded entity.