Bounding Sphere

Hey everyone,

I was wondering if there is a way to make a collision sphere, using boundingSphere, and to use with intersects mesh?
something like this but not intersectpoint intersects mesh

https://www.babylonjs-playground.com/#IK3V1A#6

https://www.babylonjs-playground.com/#NYWMTI

https://www.babylonjs-playground.com/#NYWMTI#2

https://www.babylonjs-playground.com/#NYWMTI#3
Testing some ideas

pseudo code. (but this is for two spheres and does not have the sqrt which you need)

if(ObjectB.position.add(ObjectA.position)).length <= (ObjectA.radius + ObjectB.radius){collision}else{no-collision}

f(A,B) = sqrt{(A_x - B_x)^2 + (A_y - B_y)^2 + (A_z - B_z)^2} <= A_{radius} + B_{radius}

1 Like

Some links to some ideas on collisions with spheres Babylon.js Documentation

1 Like

Hey guys, take a look at this method.
Instead of using intersectMesh, use intersectsSphere, then the boundingSphere

https://www.babylonjs-playground.com/#NYWMTI#4

I think it works rather well, what are your thoughts?

1 Like