# PointerDragBehavior with collision

**URL:** <https://forum.babylonjs.com/t/pointerdragbehavior-with-collision/153>\
**Category:** Questions\
**Created:** [December 11, 2018, 11:11am UTC](https://forum.babylonjs.com/t/pointerdragbehavior-with-collision/153 "2018-12-11T11:11:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bestog](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bestog/32/89_2.png) [@bestog](https://forum.babylonjs.com/u/bestog)\
**Post date:** [December 11, 2018, 11:11am UTC](https://forum.babylonjs.com/t/pointerdragbehavior-with-collision/153/1 "2018-12-11T11:11:31Z")

</div>

How can I adjust that the mesh collides with a wall when it is moved and cannot be moved outside the wall? (Example: Room with couch to move).

Thank you 🙂

---

<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:** [December 11, 2018, 2:38pm UTC](https://forum.babylonjs.com/t/pointerdragbehavior-with-collision/153/2 "2018-12-11T14:38:49Z")

</div>

Pinging @trevordev

---

<div class="post-metadata">

**Author:** ![trevordev](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/trevordev/32/16_2.png) [@trevordev](https://forum.babylonjs.com/u/trevordev)\
**Post date:** [December 11, 2018, 6:44pm UTC](https://forum.babylonjs.com/t/pointerdragbehavior-with-collision/153/3 "2018-12-11T18:44:00Z")

</div>

Does this example work for you? [Babylon.js Playground](https://playground.babylonjs.com/#2N6Q9H)

It checks the position when moving and if it collides it sets the position to the previous

---

<div class="post-metadata">

**Author:** ![timetocode](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/timetocode/32/111_2.png) [@timetocode](https://forum.babylonjs.com/u/timetocode)\
**Post date:** [December 12, 2018, 12:37am UTC](https://forum.babylonjs.com/t/pointerdragbehavior-with-collision/153/4 "2018-12-12T00:37:32Z")

</div>

Cool feature! I didn’t know this existed.

I was playing with trevordev’s example and added wall sliding. The movement of the sphere is done in two stages, and if it can continue to move in x or z it does. This does not handle rotation, so use is limited.

[https://playground.babylonjs.com/#WMMKTN](https://playground.babylonjs.com/#WMMKTN)
