Detecting where a part hits another part

Hello, I am looking to find the position of where a part hits another part. Picture below.

For this I will be calling the position where one part collides with another p1. So how could I find p1? I’ve already tried raycasting, but found that it was inaccurately detecting where the position of where it hit was. In what ways could I go about solving this problem?

1 Like

Maybe use ZonePlus v3.2.0 | Construct dynamic zones and effectively determine players and parts within their boundaries ZonePlus made by ForeverHD this module helps you detect when parts hits each others using Zones.


Intersection between two different parts should probably be calculated as best. Alternatively, you could resort to the modules that work with this.

1 Like

What application do you need this for?

What assumptions about the parts can you make (shape, size, rotation, velocity)?

I need this for a physics based game I am working on. I am trying to make a sparks effect from where a ball and a random object collide with each other.

Well, there’s no built in way.

Consider faking it and just creating the sparks at the balls position. Maybe it’ll look fine.

Otherwise, you could either

  1. Fire a bunch of raycasts out in a sphere and pick the one that’s closest to approximate the contact point, or

  2. Implement sphere-“random shape” intersection calculations for all the possible shapes you could have. There is lots of info online for doing this with spheres and different shapes, but it’s not easy.

I recommend option 1.

Since you are using a ball, can’t you just move outwards from the center of the ball in the direction of the part it is hitting. You would move outwards only the radius length. It probably won’t be accurate for non-equal side length shapes because the center is elsewhere but I dunno.