0
votes

I am creating a simple breakout game using SpriteKit and am having an issue where the ball seems to hit off the edge of the bricks even when they are stacked next to each other.

The ball should bounce as though it's bouncing off of a smooth surface, however, it's almost like the bricks' physics bodies aren't fully realized until after the ball has made the first contact.

I have tried several things to solve the problem such as overlapping the bricks by a few pixels, turning on usesPreciseCollisionDetection. However, these don't seem to be having any effect.

This is how I am creating the bricks' physics bodies:

brick.physicsBody = SKPhysicsBody(rectangleOf: brick.frame.size)

Is there something that I am missing, or is this an issue with SpriteKit?

Image of issue

1
Not following you... how do you bounce off of anything other than an edge? - Knight0fDragon

1 Answers

0
votes

After the fist contact the ball probably get angular velocity, this can change your expected bounce.

If you look this example: https://github.com/Maetschl/SpriteKitExamples/tree/master/BouncingBalls

The second ball has an angular velocity, this change the direction of the bounce:

enter image description here

Check this property: ballNode.physicsBody?.angularVelocity and make it 0.