Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Ball bounce physics is off when ball bounces in-between sprites

Discussion in 'Editor & General Support' started by ahcollin, Apr 4, 2022.

  1. ahcollin

    ahcollin

    Joined:
    Jan 12, 2016
    Posts:
    7
    Hi peeps,

    Working on a brick breaker style game, and I'm having problems with getting the ball to bounce at accurate angles when the ball hits in the exact spot between 2 bricks. Here's a video with an example. You can see the balls don't bounce at the correct angle at first, and then once the brick on the left is destroyed, the physics behaves normally.



    The bricks are sprites with Rigidbody2D and BoxCollider2D. Here's the collider boundaries:

    https://imgur.com/nu2O7Iz

    Both the ball and bricks are set to use a PhysicsMaterial2D with Friction 0 and Bounciness 1. The ball uses a Rigidbody2D and CircleCollider2D.

    Any idea what's happening or how to fix this?
    Thanks! I really appreciate your help.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,954
    You will likely need to do your own collision testing with something like Raycast, otherwise each interaction will be unpredictable and dependent on the detected overlaps of each given collider.
     
  3. ahcollin

    ahcollin

    Joined:
    Jan 12, 2016
    Posts:
    7
    Is there a way to merge colliders between sprites?

    If I do ditch the normal unity rigidbody physics, would using Vector3.reflect be a good option? Seems like it might work out.