# After a collision, stop moving

**URL:** <https://discourse.threejs.org/t/after-a-collision-stop-moving/44653>\
**Category:** Questions\
**Tags:** transform, geometry\
**Created:** [November 14, 2022, 3:10am UTC](https://discourse.threejs.org/t/after-a-collision-stop-moving/44653 "2022-11-14T03:10:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![miao-liu](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/miao-liu/32/27639_2.png) [@miao-liu](https://discourse.threejs.org/u/miao-liu)\
**Post date:** [November 14, 2022, 3:10am UTC](https://discourse.threejs.org/t/after-a-collision-stop-moving/44653/1 "2022-11-14T03:10:33Z")

</div>

Hello,everyone!  
As shown in the title, let me give an example to explain in detail: when a group moves to the left on the x-axis and encounters other groups, if it continues to move to the left, it stops moving.

[code](https://codepen.io/miao-liu/pen/JjZRmaM)  
My question: If you approach slowly, there is no gap between the stops, if you move fast, there is a gap between the stops after impact.  
My idea to remove the spacing is to judge its direction, then measure the position between the two meshes, if it’s the y-axis, then subtract half of the respective heights, if it’s the x-axis, subtract half of the respective widths, if it’s the z-axis , minus half of their respective depths. Then add the dwell position of the mesh before impact. It feels cumbersome, is there a better solution?
