1
\$\begingroup\$

I have been making a brick breaker game in Unity in 2D as my first game. I have got the ball bouncing off the paddle correctly and can bounce it of the paddle at different angles. However, when the ball hits a wall or the roof it always bounces so its either traveling exactly in the X-directon or Y-direction regardless of what angle it hits the wall with instead of bouncing off at 90'.

Im not using any scripts to control the bouncing off the walls or roof just using 2D box colliders on the roof and walls (which are cubes) and a circle collider and 2D rigidbody on the ball (sphere) which Ive given a bouncy material.

Any help would be really appreciated.

Here's a gif of the problem: https://i.sstatic.net/xvtgY.jpg

\$\endgroup\$
3
  • \$\begingroup\$ Can you include the physics material properties for your ball and the walls? It looks like either the ball is losing too much of its velocity parallel to the wall via friction, or it's getting overwhelmed by flubber-like excess momentum in the perpendicular direction. \$\endgroup\$
    – DMGregory
    Commented Sep 2, 2016 at 1:42
  • \$\begingroup\$ I gave the ball a Physics2D Material with bounciness 1 and friction 0.4, and the walls are simply cubes that i swapped the box colliders for 2Dbox colliders \$\endgroup\$
    – R-4
    Commented Sep 2, 2016 at 1:49
  • \$\begingroup\$ Try setting its friction to 0, and use this for the walls too. See if that changes the behaviour. You may also want to constrain rotation on the ball to eliminate spin as a factor. \$\endgroup\$
    – DMGregory
    Commented Sep 2, 2016 at 1:51

1 Answer 1

2
\$\begingroup\$

Typing up an answer based on our troubleshooting in the comments above:

It looked to me like your ball was suddenly losing a lot of its momentum in the direction parallel to the wall, as soon as it impacted. That could be a sign that the friction value in its PhysicsMaterial2D is too high.

Setting friction to zero on the ball should help.

In 3D, you'd also set FrictionCombine to Minimum or Multiply to ensure it stays zero even if it strikes an object with a high friction value.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .