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?
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.
Consider faking it and just creating the sparks at the balls position. Maybe it’ll look fine.
Otherwise, you could either
Fire a bunch of raycasts out in a sphere and pick the one that’s closest to approximate the contact point, or
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.
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.