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

Applying force to a rigid body causes it to pass through colliders.

Discussion in 'Physics' started by katarn321, Apr 6, 2020.

  1. katarn321

    katarn321

    Joined:
    May 8, 2019
    Posts:
    5
    Ive got a sphere with a rigid body and a sphere collider on it. I have an object shaped like an arch I made in blender. The arch has a mesh collider on it but no rigid body. I create a plane, turn the arch on its back and lay it on the plane (like the top end of a pinball machine's play surface). I put the sphere on the same plane and use a script to .AddForce on the rigid body just once on FixedUpdate to fire it towards the arch.

    The sphere takes off toward the arch but when it encounters the object instead of bouncing or following the surface of the arch it passes straight through like there was no collider on the arch.

    Now the weird part. If I rotate the plane 90 degrees so the arch is at the bottom and the sphere above it. If I comment out the AddForce line in the script, so the script is basically doing nothing, and let gravity act on the sphere it falls toward the arch and when it gets to it it encounters the collider on the arch and follows the curve like I would expect.

    I have no idea why when the plane is flat and the sphere is rolling along it towards the arch using AddForce it passes straight through the arch.

    Thanks in advance.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    Maybe you've heard of the saying, "a picture paints a thousand words". :)

    Describing interactions like this is very difficult for others to follow nevermind advise you on. Images/videos make the job much easier.
     
  3. katarn321

    katarn321

    Joined:
    May 8, 2019
    Posts:
    5
    While trying to put together a couple videos demonstrating the issue I couldn't replicate things exactly. For the most part the sphere would pass through the colliders whether it was by using a script to add force or letting gravity do it. I had 4 or 5 different arches I had made in testing and one of them worked as I was hoping where the sphere always respected the colliders and didn't pass through. Don't know if it was simply from shutting down and restarting things or what. Anyway, for reference I was using 2019.3.7f1.

    Thanks for responding anyway. Im just going to go with what I have now which seems to be working ok.
     
    MelvMay likes this.
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    Glad you got it working.