|
Hey, 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! Thanks, Wes
(comments are locked)
|
|
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. Could you please post some code examples? TIA, R.
Dec 14 '10 at 08:44 PM
user-7417 (google)
(comments are locked)
|

hi wes, I'm assuming that colliders are attached to your walls, yes? Is the 'isKinematic' flag on your wall and rigidbody colliders turned off (unchecked)?
Hi Dendro. Yes, I have colliders on the walls and isKinematic is turned off. I think it has to do with the speed of rigidbody as if I slowly drag the RB, it collides correctly. I also changed collision to continuous dynamic as this is supposed to account for high speed collisions, but it's not working either.