Snap mesh on local X,Z axis of another object while moving?

In this scenario https://www.babylonjs-playground.com/#YTVDR0#2 I have 2 black boxes.

The first box is following the mouse and the other (box2) is positioned at (1,1,1).

While the fist box is moving, I want it to snap on the local X OR Z axis of box2.

The first box doesn’t have to stay on the local axis all the time. Just need to snap when its nearby.

How can I achieve this?

Hey, something like this?
https://www.babylonjs-playground.com/#YTVDR0#3

3 Likes

Thanks I was able to change the code a bit to make it exactly as I wanted.

It showed me how this works.

1 Like