# Drag collision effect

**URL:** <https://forum.babylonjs.com/t/drag-collision-effect/7937>\
**Category:** Questions\
**Created:** [January 9, 2020, 9:45am UTC](https://forum.babylonjs.com/t/drag-collision-effect/7937 "2020-01-09T09:45:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lp920133349](https://avatars.discourse-cdn.com/v4/letter/l/7feea3/32.png) [@lp920133349](https://forum.babylonjs.com/u/lp920133349)\
**Post date:** [January 9, 2020, 9:45am UTC](https://forum.babylonjs.com/t/drag-collision-effect/7937/1 "2020-01-09T09:45:57Z")

</div>

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/0/060c308cb1da78f24ef73fb652f27d2287d55729.jpeg)  
I pass let pointerDragBehavior = new BABYLON. PointerDragBehavior ({dragPlaneNormal: new BABYLON, Vector3 (0, 0)});Make these small box drag effect, but I also hope that box will be a collision in the process of drag effect, is the box won’t overlap, now in the process of the drag and drop box overlap, I used the mesh. The checkCollisions = true, but useless, which master can help me solve

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [January 9, 2020, 3:46pm UTC](https://forum.babylonjs.com/t/drag-collision-effect/7937/2 "2020-01-09T15:46:28Z")

</div>

Pinging @Cedric

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [January 9, 2020, 4:13pm UTC](https://forum.babylonjs.com/t/drag-collision-effect/7937/3 "2020-01-09T16:13:54Z")

</div>

Hi @lp920133349

So, if I understand correctly, you want a physic response between boxes when you drag one with the mouse.  
The solution to use depends on what you expect. If the other boxes can be pushed when a collision happens and move accordingly, you need to add a physic impostor per box.  
If you simply want to constrain the dragged box by the other boxes, then you can add a check to the PointerDragBehavior and allow or not allow the new box position.

Let me know what you want to do and I’ll do a quick playground 🙂 .

---

<div class="post-metadata">

**Author:** ![buddy90210](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/buddy90210/32/12955_2.png) [@buddy90210](https://forum.babylonjs.com/u/buddy90210)\
**Post date:** [January 18, 2021, 4:14am UTC](https://forum.babylonjs.com/t/drag-collision-effect/7937/4 "2021-01-18T04:14:36Z")

</div>

> [@Cedric](#):
>
> If you simply want to constrain the dragged box by the other boxes, then you can add a check to the PointerDragBehavior and allow or not allow the new box position.
> 
> Let me know what you want to do and I’ll do a quick playground 🙂 .

Hello, can you do it for me? 😀

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [January 18, 2021, 9:24am UTC](https://forum.babylonjs.com/t/drag-collision-effect/7937/5 "2021-01-18T09:24:28Z")

</div>

I’m very busy at the moment but if you have issues, I’ll be happy to check your PG.

---

<div class="post-metadata">

**Author:** ![lxq100](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lxq100/32/43689_2.png) [@lxq100](https://forum.babylonjs.com/u/lxq100)\
**Post date:** [April 1, 2024, 2:49am UTC](https://forum.babylonjs.com/t/drag-collision-effect/7937/6 "2024-04-01T02:49:22Z")

</div>

```auto
pointerDragBehavior.moveAttached = false
pointerDragBehavior.onDragObservable.add((eventData) => {
    base.moveWithCollisions(eventData.delta)
})

```

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

Does it meet your needs?
