- Home /
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.
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
I don't think code would help, it just positions and rounds object's coordinates.
You could probably use the bounds of the meshes and do a bounds check.
renderer.bounds returns bounds affected by transform, so rotations will work. This works for any mesh.
Answer by Sarthak123 · Dec 06, 2014 at 01:47 PM
Simple, use Raycasting to detect objects nearby, play around with it, do this -
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.
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.
Your answer
Follow this Question
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