I've created a ball, and boxed my game scene.
The balls physics settings are:
self.physicsBody!.affectedByGravity = true
self.physicsBody!.restitution = 1.0
self.physicsBody!.linearDamping = 0
self.physicsBody!.friction = 0.3
self.physicsBody!.isDynamic = true
self.physicsBody!.mass = 0.5
self.physicsBody?.contactTestBitMask = bodyMasks.blankMask.rawValue
self.physicsBody?.collisionBitMask = bodyMasks.edgeMask.rawValue
self.physicsBody?.categoryBitMask = bodyMasks.ballMask.rawValue
When I box the game scene with:
self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)
the ball bounces back up as intended.
However, if I replace edgeLoopFrom with my own custom borders:
yourLine.lineWidth = 5
yourLine.path = pathToDraw
yourLine.isUserInteractionEnabled = false
yourLine.strokeColor = .clear
yourLine.isHidden = false
yourLine.zPosition = 10
yourLine.physicsBody = SKPhysicsBody(edgeLoopFrom: pathToDraw)
yourLine.physicsBody?.affectedByGravity = false
yourLine.physicsBody?.pinned = true
yourLine.physicsBody?.categoryBitMask = bodyMasks.edgeMask.rawValue
yourLine.physicsBody?.collisionBitMask = bodyMasks.ballMask.rawValue
yourLine.physicsBody?.contactTestBitMask = bodyMasks.blankMask.rawValue
the ball just comes down with a thud, stops, and doesn't bounce.,
So am trying to figure out what physics settings I have to give to my custom made edges so that the ball bounces?
And their restitutions doesn't combine, the software just used the higher one?
restitution is how much energy the physics body loses when it bounces off another object.
So it seems logical to have 0.8 as a result.
You should try:
ball.restitution = 0.4 // <<-- Swapped with block
block.restitution = 0.8
My guess would be
restitution used by physics engine should be 0.4