# Find the distance between two meshes

**URL:** <https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346>\
**Category:** Questions\
**Created:** [April 3, 2019, 7:52pm UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346 "2019-04-03T19:52:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Givo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/givo/32/4968_2.png) [@Givo](https://forum.babylonjs.com/u/Givo)\
**Post date:** [April 3, 2019, 7:52pm UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346/1 "2019-04-03T19:52:44Z")

</div>

Hi!

I have two objects, and I’m trying to find the distance between them. I hope this is possible, and if at all possible I would like a single digit number. Kinda like the getlinearvelocity for physics objects.

Thanks for any help, sorry if it is hard to understand.

Givo

---

<div class="post-metadata">

**Author:** ![QuintusHegie](https://avatars.discourse-cdn.com/v4/letter/q/977dab/32.png) [@QuintusHegie](https://forum.babylonjs.com/u/QuintusHegie)\
**Post date:** [April 3, 2019, 8:01pm UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346/2 "2019-04-03T20:01:25Z")

</div>

(For the distance between the meshes centers…) take world (absolute) position vector of mesh 1 and subtract world (absolute) position vector of mesh, then take the length() function.

[https://doc.babylonjs.com/api/classes/babylon.vector3](https://doc.babylonjs.com/api/classes/babylon.vector3)

I’d recommend the book Mathematics for 3D Game Programming and Computer Graphics if you’d like to learn some essential/handy math for 3D projects:

> **[Mathematics for 3D Game Programming and Computer Graphics, Third Edition](https://www.amazon.com/Mathematics-Programming-Computer-Graphics-Third/dp/1435458869)**
>
> 4.1 out of 5 stars, 
> ISBN: 978-1435458864, 
> Cengage Learning PTR, 
> June 2, 2011, 
> $52.71

---

<div class="post-metadata">

**Author:** ![withADoveInOneHand](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/withadoveinonehand/32/1243_2.png) [@withADoveInOneHand](https://forum.babylonjs.com/u/withADoveInOneHand)\
**Post date:** [April 3, 2019, 11:48pm UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346/4 "2019-04-03T23:48:36Z")

</div>

Oh, _yoink_.

I was using BABYLON.Vector3.Distance(p1,p2) btw.

---

<div class="post-metadata">

**Author:** ![Givo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/givo/32/4968_2.png) [@Givo](https://forum.babylonjs.com/u/Givo)\
**Post date:** [April 4, 2019, 2:28am UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346/5 "2019-04-04T02:28:59Z")

</div>

I give you an answer, and you do the same to me! 🙃  
Thanks for the help.

---

<div class="post-metadata">

**Author:** ![QuintusHegie](https://avatars.discourse-cdn.com/v4/letter/q/977dab/32.png) [@QuintusHegie](https://forum.babylonjs.com/u/QuintusHegie)\
**Post date:** [April 4, 2019, 5:10pm UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346/6 "2019-04-04T17:10:22Z")

</div>

Cool @withADoveInOneHand ! That function Distance on Vector3 will save me some code lines on making the Math myself. From time to time, new functions appear in the API (at least to me) that make my code easier and smaller. Whoohoo 🙂

Thanks for the online PDF copy of the book @Givo I had bought the book already earlier with my business budget to show support to the author. And as a expert on several business and IT topics I get send most books for free anyways to review…

---

<div class="post-metadata">

**Author:** ![aWeirdo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aweirdo/32/52_2.png) [@aWeirdo](https://forum.babylonjs.com/u/aWeirdo)\
**Post date:** [April 4, 2019, 8:53pm UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346/7 "2019-04-04T20:53:27Z")

</div>

Hi @Givo  
Please avoid posting anything illegal 🙂  
[https://forum.babylonjs.com/faq#stealing](https://forum.babylonjs.com/faq#stealing)

---

<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:** [April 4, 2019, 8:57pm UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346/8 "2019-04-04T20:57:50Z")

</div>

Fixed!

---

<div class="post-metadata">

**Author:** ![Givo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/givo/32/4968_2.png) [@Givo](https://forum.babylonjs.com/u/Givo)\
**Post date:** [April 5, 2019, 12:29am UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346/9 "2019-04-05T00:29:52Z")

</div>

Sorry.

> [@QuintusHegie](#):
>
> Thanks for the online PDF copy of the book

I did a google search. @Deltakosh is it stealing if I post my google search query?

> [@aWeirdo](#):
>
> Please avoid posting anything illegal

Sorry. 😶 I just thought I would put it out there.

---

<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:** [April 5, 2019, 2:05pm UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346/10 "2019-04-05T14:05:36Z")

</div>

You should just communicate using PM in that case

---

<div class="post-metadata">

**Author:** ![Givo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/givo/32/4968_2.png) [@Givo](https://forum.babylonjs.com/u/Givo)\
**Post date:** [April 6, 2019, 10:47am UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346/11 "2019-04-06T10:47:27Z")

</div>

ok.

---

<div class="post-metadata">

**Author:** ![nady](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nady/32/12312_2.png) [@nady](https://forum.babylonjs.com/u/nady)\
**Post date:** [October 19, 2020, 7:43am UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346/12 "2020-10-19T07:43:53Z")

</div>

Is there a code or playground i can see, how to measure distance using pickedMesh between two opoints ?

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [October 19, 2020, 2:51pm UTC](https://forum.babylonjs.com/t/find-the-distance-between-two-meshes/2346/13 "2020-10-19T14:51:35Z")

</div>

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