# When I move the object next to another object with the mouse, I want them to come side by side without any space between them, like a magnet?

**URL:** <https://forum.babylonjs.com/t/when-i-move-the-object-next-to-another-object-with-the-mouse-i-want-them-to-come-side-by-side-without-any-space-between-them-like-a-magnet/44848>\
**Category:** Questions\
**Created:** [October 12, 2023, 10:04am UTC](https://forum.babylonjs.com/t/when-i-move-the-object-next-to-another-object-with-the-mouse-i-want-them-to-come-side-by-side-without-any-space-between-them-like-a-magnet/44848 "2023-10-12T10:04:29Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [October 18, 2023, 10:37am UTC](https://forum.babylonjs.com/t/when-i-move-the-object-next-to-another-object-with-the-mouse-i-want-them-to-come-side-by-side-without-any-space-between-them-like-a-magnet/44848/21 "2023-10-18T10:37:22Z")

</div>

I think I understood, you want the two boxes to stick their **edges** together ?  
I won’t know how to do that to help you.

Maybe someone else will have an idea.

---

<div class="post-metadata">

**Author:** ![Melih](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/melih/32/35454_2.png) [@Melih](https://forum.babylonjs.com/u/Melih)\
**Post date:** [October 18, 2023, 10:38am UTC](https://forum.babylonjs.com/t/when-i-move-the-object-next-to-another-object-with-the-mouse-i-want-them-to-come-side-by-side-without-any-space-between-them-like-a-magnet/44848/22 "2023-10-18T10:38:06Z")

</div>

this is exactly what i want

---

<div class="post-metadata">

**Author:** ![Melih](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/melih/32/35454_2.png) [@Melih](https://forum.babylonjs.com/u/Melih)\
**Post date:** [October 18, 2023, 12:03pm UTC](https://forum.babylonjs.com/t/when-i-move-the-object-next-to-another-object-with-the-mouse-i-want-them-to-come-side-by-side-without-any-space-between-them-like-a-magnet/44848/23 "2023-10-18T12:03:46Z")

</div>

> **[Babylon.js Playground](https://playground.babylonjs.com/#9F1EA3%235)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Two objects attract each other from all directions, but I want them to stop as soon as they touch each other. The objects overlap each other, how can I solve this problem?

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [October 18, 2023, 12:08pm UTC](https://forum.babylonjs.com/t/when-i-move-the-object-next-to-another-object-with-the-mouse-i-want-them-to-come-side-by-side-without-any-space-between-them-like-a-magnet/44848/24 "2023-10-18T12:08:08Z")

</div>

You need to detect when objects overlap and stop the attraction. See: [Mesh Intersections | Babylon.js Documentation (babylonjs.com)](https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/mesh_intersect)

---

<div class="post-metadata">

**Author:** ![Melih](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/melih/32/35454_2.png) [@Melih](https://forum.babylonjs.com/u/Melih)\
**Post date:** [October 19, 2023, 7:12am UTC](https://forum.babylonjs.com/t/when-i-move-the-object-next-to-another-object-with-the-mouse-i-want-them-to-come-side-by-side-without-any-space-between-them-like-a-magnet/44848/25 "2023-10-19T07:12:09Z")

</div>

> **[Babylon.js Playground](https://playground.babylonjs.com/#9F1EA3%238)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

I solved the problem, but I want to use any model instead of the sphere object, but it does not have the features of sphere. How can I solve this problem? It is necessary to have any model instead of sphere

[Previous page](https://forum.babylonjs.com/t/when-i-move-the-object-next-to-another-object-with-the-mouse-i-want-them-to-come-side-by-side-without-any-space-between-them-like-a-magnet/44848.md?page=1)
