Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1-800-jono/d168e8d8b2d3986fd6e161f07a71ad5e to your computer and use it in GitHub Desktop.
Save 1-800-jono/d168e8d8b2d3986fd6e161f07a71ad5e to your computer and use it in GitHub Desktop.
Find distance between to objects in 3D.
var p1 = objectOne.position;
var p2 = objectTwo.position;
var distance = Math.sqrt(
(p1.x - p2.x) * (p1.x - p2.x) + (p1.z - p2.z) * (p1.z - p2.z)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment