# pointerDragBehavior questions

**URL:** <https://forum.babylonjs.com/t/pointerdragbehavior-questions/39198>\
**Category:** Questions\
**Created:** [March 20, 2023, 3:56pm UTC](https://forum.babylonjs.com/t/pointerdragbehavior-questions/39198 "2023-03-20T15:56:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Biscuit](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@Biscuit](https://forum.babylonjs.com/u/Biscuit)\
**Post date:** [March 20, 2023, 3:56pm UTC](https://forum.babylonjs.com/t/pointerdragbehavior-questions/39198/1 "2023-03-20T15:56:54Z")

</div>

Hi, … long time,  
I hope you are all good!

I have a couple of questions about pointerDragBehavior. I hope you can help me

1. Can I change the cursor on the mesh which has attached the pointerDragBehavior? I know I can do this with actionManager, but I’m curious if I can do this somehow from pointerDragBehavior.
2. How I can validate a drag? As example to work only between some values … Meanwhile I found the answer for this 😅

validateDrag

is the answer  
3. How I can add a step to this? As example I want to be able to drag it only from integer unit to integer unit, or with a step of 2  
4. I have as example 5 objects, and I want to be able to drag them in an interval but in the same time to keep a min distance between them. Can I do this with pointerDragBehavior or shall I use the default event system?  
They are positioned like this

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/d/0dd96842160663c5aff595c221ea2dc27995b764.png)  
And at the end they will look like this  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/f/0fef9db43aa0b52868f4fefa06334dffc9a93db6.png)  
I tried to simulate the drag but keep that min distance between them

I have a playground as well, where I tried few things

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

btw, I’m so excited about the new version of BABYLONJS  
Thank you so much!

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [March 20, 2023, 6:53pm UTC](https://forum.babylonjs.com/t/pointerdragbehavior-questions/39198/2 "2023-03-20T18:53:40Z")

</div>

cc @PolygonalSun

---

<div class="post-metadata">

**Author:** ![Biscuit](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@Biscuit](https://forum.babylonjs.com/u/Biscuit)\
**Post date:** [March 29, 2023, 5:50pm UTC](https://forum.babylonjs.com/t/pointerdragbehavior-questions/39198/3 "2023-03-29T17:50:14Z")

</div>

Hi,  
I made some progresses

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

I hope I’m on the right way 🤔

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [March 29, 2023, 7:55pm UTC](https://forum.babylonjs.com/t/pointerdragbehavior-questions/39198/4 "2023-03-29T19:55:15Z")

</div>

Assigned @PolygonalSun on March 29, 2023, 7:55pm UTC



---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [March 30, 2023, 9:00pm UTC](https://forum.babylonjs.com/t/pointerdragbehavior-questions/39198/5 "2023-03-30T21:00:59Z")

</div>

Hey Biscuit,  
As far as changing the cursor, you’d either need to use an actionManager or you’d have to manually change the cursor style (eg. `canvas.cursor.style="wait"`, I think). If you’re trying to move by some integer or fixed value, you could always just store the dragDistance and just move it when it breaks some threshold value. For example:

```auto
var dragDeltas = 0;
...
...onDragObservable.add(event => {
    dragDeltas += event.dragDistance;
    const intMove = Math.round(dragDeltas);
    if (intMove !== 0) {
        // Move object by intMove
        ...
        // Reset dragDeltas for next move
        dragDeltas = 0;
    }
});

```

For your last question, you could always try enabling collisions on your meshes and using `moveWithCollisions(/* Vector of Movement */)`. For spacing, you could also create an invisible mesh to act as a collision box. Here’s a crude example: [https://playground.babylonjs.com/#L6RQEI#2](https://playground.babylonjs.com/#L6RQEI#2).

Keep in mind, that these aren’t the only solutions to these questions. These are just the ones that come to mind. Hopefully, these tips can help you out.

---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [March 30, 2023, 9:01pm UTC](https://forum.babylonjs.com/t/pointerdragbehavior-questions/39198/6 "2023-03-30T21:01:02Z")

</div>

Unassigned @PolygonalSun on March 30, 2023, 9:01pm UTC



---

<div class="post-metadata">

**Author:** ![Biscuit](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@Biscuit](https://forum.babylonjs.com/u/Biscuit)\
**Post date:** [April 14, 2023, 12:01pm UTC](https://forum.babylonjs.com/t/pointerdragbehavior-questions/39198/7 "2023-04-14T12:01:07Z")

</div>

Hi, thank you so much @PolygonalSun for the insights, I’ll try and come back with updates!
