# Collision and "attachment points"

**URL:** <https://forum.babylonjs.com/t/collision-and-attachment-points/23678>\
**Category:** Questions\
**Created:** [September 8, 2021, 7:34pm UTC](https://forum.babylonjs.com/t/collision-and-attachment-points/23678 "2021-09-08T19:34:54Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [September 9, 2021, 11:46pm UTC](https://forum.babylonjs.com/t/collision-and-attachment-points/23678/4 "2021-09-09T23:46:00Z")

</div>

Coincidently Jason answered at the same time I was working on a quick demo of how I’d approach this 😆

[https://playground.babylonjs.com/#2MNDQN#1](https://playground.babylonjs.com/#2MNDQN#1)

I think the invisible object would definitely be a good example to start. In my playground, I used the green box as the attachment point (of course, this would be invisible in an actual aplication, but it’s easier to explain the idea when it’s visible).

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/a/eaf4dedaee0ff1c2a27e2bef95c3cf89e4fccd87.png)

When I click the yellow box and start dragging on the x direction, I keep track of what are going to be the future bounds of the object and compare them to the green box’s bounds. If they overlap, then I “snap” the yellow box to a fixed position and stop the dragging behaviour. The green box is slightly bigger than the red box because having such a “breather space” in intersections usually lead to better experience for the user.

---

_[View the full topic](https://forum.babylonjs.com/t/collision-and-attachment-points/23678)._
