I also have a ball that has a sphere collider and a rigid body with the following parameters:
Problem
When the ball has velocity and gets hit by rectangle the rectangle drags the ball with it, which seems fine. But if the ball is stationary the rectangle just moves through it. Sometimes it seems like the rectangle will first move through the ball and then when coming around the other way it starts dragging the ball. What is going on, why won’t a stationary ball with rigid body and collider react to colliding with a moving object with a collider on it?
It’s not moving in any physics sense. Your “rectangle with a box collider” might have a collider on but it’s not physics movement; it’s you directly modifying the Transform and therefore teleporting the collider from position to position. Also, you’re doing this per-frame completely ignoring that physics doesn’t, by default, run per-frame.
If it moves in physics, move a Rigidbody (which writes to the Transform) and use its API such as adding forces, setting velocity or use MovePosition etc. For the code above, it should have a Rigidbody set to be Kinematic and you should use MovePosition. You should also do this during the FixedUpdate and set interpolation on the Rigidbody so it’s visually smooth. When referencing the current position, don’t use the Transform.position, use the Rigidbody.position as it is the authority on the current pose; the Transform is just for visuals.
Thank you very much, lots of things I had no clue about. Adding a kinematic rigid body seems to fix the issue. Will implement the rest as well if troubles come back.