• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by The 3D Ninja · Dec 07, 2010 at 03:03 AM · collisionrigidbodytouchdragkinematic

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

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image zannghast · Dec 07, 2010 at 04:56 AM 0
Share

hi wes, I'm assu$$anonymous$$g that colliders are attached to your walls, yes? Is the 'is$$anonymous$$inematic' flag on your wall and rigidbody colliders turned off (unchecked)?

avatar image The 3D Ninja · Dec 08, 2010 at 02:24 PM 0
Share

Hi Dendro. Yes, I have colliders on the walls and is$$anonymous$$inematic 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.

2 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by The 3D Ninja · Dec 09, 2010 at 05:03 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image user-7417 (google) · Dec 14, 2010 at 08:44 PM 0
Share

Could you please post some code examples?

TIA, R.

avatar image
0

Answer by joshuapeacock · Jun 11, 2018 at 06:42 PM

The accepted answer does not work in my situation I need precise movement control. But I have the same situation where I am moving a rigidbody with swipe input and on mobile device with movePosition. I cannot find a solution anywhere to provide continuous collision detection when use movePosition.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Rigidbody and Parenting - Kinematic Rigidbodies? 2 Answers

Simple Movement Game: Physics vs Manual Collision Detection? 2 Answers

Objects with colliders going through walls and each other. 3 Answers

2D motion/collision: physics, or direct translation? 2 Answers

Disable rigidbody from being able to move other rigidbodies 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges