Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by Avash · Dec 06, 2014 at 11:53 AM · c#physicscollidercolliders

How to check is object directly next to another object?

Eg. Chek if cube in 0, 0, 1 is touching a cube in 0, 0, 0 (but not colliding)? In other situations objects might be rotated. I have a snapped object and I need to know is it touching other object.

Comment
Add comment · Show 7
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 b1gry4n · Dec 06, 2014 at 12:21 PM 0
Share

directly next to an object is too vague. This can be achieved in so many ways. Why dont you expand on how you are placing these objects, what these objects represent, and applicable code used

avatar image Avash · Dec 06, 2014 at 12:50 PM 0
Share

I don't think code would help, it just positions and rounds object's coordinates.

avatar image EvilTak · Dec 06, 2014 at 12:51 PM 0
Share

You could probably use the bounds of the meshes and do a bounds check.

avatar image Avash · Dec 06, 2014 at 12:59 PM 0
Share

Does that work with custom meshes and rotations?

avatar image EvilTak · Dec 06, 2014 at 01:04 PM 0
Share

renderer.bounds returns bounds affected by transform, so rotations will work. This works for any mesh.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Sarthak123 · Dec 06, 2014 at 01:47 PM

Simple, use Raycasting to detect objects nearby, play around with it, do this -

  1. create a simple script raycasting from one side, and return the distance between the object it hits such that you can see, for example use debug.log, play around with it until you find the exact distance you want to compare, i think it would be 0.5, once you get it, then make your script whatever you need to do in it.

  2. You can also try, renderer.bounds and physics.overlap sphere to make it compact, however raycasting is just basic, as others said, these commands will help more.

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.

Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Reset a collider during runtime to lose previous Physics.IgnoreCollision() calls 1 Answer

Drag and Drop Objects in Game Problem 2 Answers

What is the best way to check is object intersecting? 1 Answer

3D player and 2D floor. I have collider problem. 1 Answer

Compound Collider - Best Practices 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