'How to make a collision boundary have a zero mass to allow objects to pass through unaffected but still set off a collision notification
I have several objects and collision boundaries defined. For one of them I would like to know when an object enters the frame of a UIimageview to set off a collisionBehaviour. However I do not want the boundary to be solid so the object can pass directly through unaffected. I understand there is a way to do this with BitMAsk in SpriteKit dynamics but I am using UIKit Dynamics. Any solutions please?
collision.addBoundary(withIdentifier: "fan1area" as NSCopying, for: UIBezierPath(rect: fan1area.frame))
animator.addBehavior(collision)
func collisionBehavior(_ behavior: UICollisionBehavior,
beganContactFor item1: UIDynamicItem,
with item2: UIDynamicItem,
at p: CGPoint) {
if String(describing: identifier) == "Optional(fan1area)" {
let pushBehavior = UIPushBehavior(items: [self.hamburger], mode: .instantaneous)
pushBehavior.angle = CGFloat(selectedValue3)
pushBehavior.magnitude = 0.05
self.animator.addBehavior(pushBehavior)
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
