Thanks Henry, for such a thorough answer.
You illustrate the problem. The last line where you call applyImpulse on physicsBody results in "Value of type 'PhysicsBodyComponent' has no member 'applyImpulse'". That's the challenge I am trying to resolve. Upon what object is applyImpulse supposed to be called on if not physicsBody as you (and I) have defined:
guard let physicsBody = tappedObject.entity.components[PhysicsBodyComponent.self] as? PhysicsBodyComponent else {
fatalError("PhysicsBodyComponent not found on the entity")
}
To further clarify, this is a gesture handler that shows the issue:
func Throw(objToThrow: EntityTargetValue<TapGesture.Value>) {
let entT = objToThrow.entity
let comp = entT.components
let pbc = comp[PhysicsBodyComponent.self]!
let physicsBodComp = pbc as PhysicsBodyComponent // Type casting is unnecessary as pbc is already a PhysicsBodyComponent
let impulse = SIMD3<Float>(x: 0.0, y: 10.0, z: 0.0)
let position = SIMD3<Float>(x: 0.0, y: 0.0, z: 0.0)
let referenceEntity: Entity? = nil
physicsBodComp.applyImpulse(impulse, at: position, relativeTo: referenceEntity); // <<< error here
}
Thanks!