I have a rigidbody that is being dragged around based off a touch input via rigidbody.movePosition. Currently, the user can drag the object through surrounding geometry such as walls. How can I stop the object from passing through the environment geometry? It happens because the object can be moved quickly. I changed detection to continuous dynamic, but it didn't help.
I have tried to use Physics.CheckSphere to see if any surrounding colliders i.e. my environment are touching the sphere. However, this always returns true. The docs are unclear as to if the checkSphere includes the collider attached the the draggable object.
I've also tried to use a Physics.Raycast to see if a collider is in front of the object based off a very small distance. This seemed to work in that I could tell I was about to hit something, but from there I wasn't sure how to stop the object from passing through the environment.
I'd greatly appreciate any advice!
I have a solution and I wanted to share it. I determined that the issue was the rigidbody was moving too quickly. I tried setting the collision detection to Continuous Dynamic, which can account for quick collisions, but this didn't work.
My solution was to apply a dampening to the drag of the rigidbody so that it was inherently slower than the finger movement. To do this, I used Vector3.SmoothDamp, which worked perfectly.
answered Dec 09 '10 at 05:03 PM
The 3D Ninja