0
votes

I'm making a game where a ball rolls down a series of blocks and the player has to anticipate where the ball is going to end up. However, I have a problem with the collision physics that I can't seem to understand.

The Problem

Whenever the ball touches the paddle (What the player moves), the ball does not stop and keeps rolling until it rolls off the paddle. What I would like to happen is for the ball to stop as soon as it touches the paddle and "stick" there. The attributes for the ball are :

enter image description here

and the attributes for the paddle are :

enter image description here

Any advice or solutions would be very helpful!

1

1 Answers

2
votes

Are you implementing a SKPhysicsContactDelegate?

If so, when you detect the collision you could set the ball's velocity to zero, like this:

ball.physicsBody?.velocity = CGVector.zero