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. Dismiss Notice

Question I have a problem with collisions in my simple prototype when objects are fast moving

Discussion in 'Physics' started by pawelpoz, Jun 25, 2023.

  1. pawelpoz

    pawelpoz

    Joined:
    Dec 9, 2015
    Posts:
    2
    I have a problem with collisions in my prototype. I would like the balls, once they enter the box, not to fall out of the box when the box is moved fast. Unfortunately, when they enter and I move the box sideways, the balls pass through the box walls.

    I move the box using physics, specifically playerRb.AddForce(forceStrength * horizontalInput, 0f, 0f).

    My box consists of several objects:an Empty object (which has a Rigidbody component with Collision Detection set to Continuous Dynamic and a slightly smaller Box Collider, with the Is Trigger option enabled for counting the balls that enter the box), and 5 nested boxes that form the walls and floor of the box.

    These 5 boxes are Cube objects with Box Colliders and the Is Kinematic option enabled (to prevent the box from falling apart). The balls that enter the box are simply Sphere objects with Sphere Colliders and Rigidbodies set to Collision Detection Continuous Dynamic.

    I will provide the link to the WebGL build below. What am I doing wrong?

    WebGL: https://play.unity.com/mg/other/webgl-builds-355553

    Unity Package: https://drive.google.com/file/d/1iojATq69mFJmwYBa-mXmbmrXaMWQ_qjI/view
     
    Last edited: Jun 25, 2023
  2. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Your walls have rigidbodies? You only need one rigidbody (in the empty parent transform). Then in child transforms you put your cube objects with box colliders but no rigidbodies.