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

Question What is causing the ball to not bounce at very specific angles?

Discussion in '2D' started by TaigaGames, Apr 11, 2023.

  1. TaigaGames

    TaigaGames

    Joined:
    Dec 14, 2019
    Posts:
    2
    I am attempting to create a Peggle clone in Unity, and I am struggling with the bounces being inconsistent.
    The blue line is made with a PhysicsScene2D and shows exactly how the ball will bounce, and I found that some very specific angles cause the ball to not bounce, as shown in the video.

    The ball's Rigidbody2D is set to continuous dynamic and I have set the Velocity Threshold to 0.0001, so I don't think those are problems.

    Does anyone know what is causing this issue and how to resolve it?


     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,620
    Without more information, it's impossible to say exactly what it is.

    What are the collision normals of the contact here? What is the "Fever Meter" composed off collider-wise? Is it a continuous surface (edges) or a bunch of boxes side-by-side etc? Maybe you're hitting a corner of one of those boxes, assuming that's what's there.

    You could merge them all together using a CompositeCollider2D in outline mode to produce a continuous surface assuming this is the issue.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,947
    Make sure you have max slipperyness on too (PhysicMaterial2Ds on all the colliders)... if you have any friction then impacts may involve torque, either increasing or decreasing the ball's angular velocity, either of which would affect its ultimate reflection angle.
     
  4. TaigaGames

    TaigaGames

    Joined:
    Dec 14, 2019
    Posts:
    2
    Update: It was a piece of code that was kind of messed up, basically doing the same thing as the velocity threshold.

    Now I'm off to fix the polygon colliders being unsmooth
     
    MelvMay likes this.