Recently I have been messing around with a collision dectection system I managed to make and which I am planning on using for a future project of mine, but i’ve ran into a problem.
The way the collision detection system works is: there are Attachments
in the middle of the BasePart
that is used as a hitbox, with a pattern resembling a wall.
When a collision happens (through a .Touched
event) it Raycasts
from all the Attachments
’ WorldPosition
in the hitbox towards the part, and if one of the Rays
hits, then the other Rays
are ignored and the hit is registered.
And here is the problem. I know how to get the distance between the Attachments
and the hit BasePart
, but I’m not really sure how to do the former and then, Raycast
from the Attachments
that are closer to the BasePart
all the way to the most distant ones. Without something like that, the collision detection tends to be weird and innacurate. (i. e. the hitbox gets hit from the left front, but the rays are fired from the front right first instead.)
Any idea of how this could be done?