x


How to stop Kinematic Rigidbody from moving through walls

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

more ▼

asked Dec 07 '10 at 03:03 AM

The 3D Ninja gravatar image

The 3D Ninja
194 12 12 22

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)?

Dec 07 '10 at 04:56 AM zannghast

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.

Dec 08 '10 at 02:24 PM The 3D Ninja
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Dec 09 '10 at 05:03 PM

The 3D Ninja gravatar image

The 3D Ninja
194 12 12 22

Could you please post some code examples?

TIA, R.

Dec 14 '10 at 08:44 PM user-7417 (google)
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2490
x1787
x579
x286
x81

asked: Dec 07 '10 at 03:03 AM

Seen: 2606 times

Last Updated: Dec 07 '10 at 03:41 AM