Good Morning,
How can I get the location of a contact between two Physicsbody via allContactedBodies?
Because of the structure of my App I cant use touchesBegan method from the Physicsbody but have to check it manually via allContactedBodies() from a Spritekit. But is there a method to get also the point where the touch occurred?
This is how I check for a contact but now I need also the position of the contact
if let unwrapped_allContactedBodies = spriteObject.spriteNode.physicsBody?.allContactedBodies() {
if spriteObject.spriteNode.physicsBody?.allContactedBodies().count ?? 0 > 0 {
return checkForContact(contactedBodies: unwrapped_allContactedBodies, parameter: value)
} else {
return 0.0
}
} else {
return 0.0
} ´´´
Any Ideas?
You can use the contact.contactPoint property. You will have to implement the SKPhysicsContactDelegate.
Example:
note: I have not tested this code in the compiler.