Thursday, March 2, 2017

c# - Unity ball not bouncing off wall correctly


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: http://imgur.com/a/YJyNH



Answer



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.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...