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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Ball going through cube when bounciness is not zero

Discussion in 'Physics' started by yoonitee, Mar 4, 2021.

  1. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,337
    The basic idea is balancing a ball on a platform.

    I have a platform which has a cube collider, which I can rotate.

    Also I have a ball on this platform with a sphere collider and a rigidbody.

    I can rotate the platfom to balance the ball. All works well so far.

    But I would also like the ball to be able to be able to bounce on the platform as well as roll around on it.

    The trouble is when I create a physics material and set bounciness of the ball or the platform >0 then when I rotate the plane, the ball passes through the platform (before slowly rising out of it).

    I have frictions of ball and platform all set to 0.1. I have sleep threshold set to 0 and bounce threshold set to 0.1. Collision detection on ball set to "continous dynamic".

    Has anyone come across this before? If so, is there a solution to set the physics settings?

    The only solution I have so far is just to turn off the bounciness to zero which is not great.

    I think I'll just implement the bouncing through scripting.
     
    Last edited: Mar 4, 2021
  2. AlTheSlacker

    AlTheSlacker

    Joined:
    Jun 12, 2017
    Posts:
    320
    Have you tried changing the physics solver type to Temporal Gauss Seidel?

    Have you tried increasing the default solver and velocity iterations?
     
    yoonitee likes this.
  3. Gauvater

    Gauvater

    Joined:
    Mar 6, 2013
    Posts:
    2
    I am observing the same problem. I have created 12 balls to experiment with all possible variations of collision detection and interpolation type, and tried various settings for the physics solver and default solver and velocity iterations, as suggested by AITheSlacker above. The balls continue to fall through the modified cube which serves as the platform, whenever I change the cube's rotation as they roll towards the edge. I also tried various collision settings for the platform.

    Perhaps this is a limitation of my system? I am new to Unity. Could someone please explain?

    EDIT:
    -Using Unity 2020.2.6f1
    -Consulted this page:https://docs.unity3d.com/ScriptReference/Rigidbody-collisionDetectionMode.html
     
    Last edited: Mar 11, 2021
  4. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,337
    What I have done so far is this:

    Set bounciness to 0.

    Write a script to detect collisions OnCollision etc. And then reflect the velocity vector when it collides. Works so far.

    Another problem I have is that when I rotate one of the platforms too fast the ball goes through it. I think it only happens with convex meshes and not if the platform is a simple cube.

    My fix for this I will try is to just overlap some cube colliders in the convex mesh to try and stop the ball going through.

    Basically just trying to hack my way though this.