I have encountered some occasional issues with the Touched Event so I have been trying to make my own detection of collisions. The following code works, but it doesn’t work with rotated parts, I was thinking I could use the CFrame’s rotation matrix to achieve my goal but I’m not sure how to do that.
function intersect(a, b)
return (a.CFrame.p.X-a.Size.X/2 <= b.CFrame.p.X+b.Size.X/2) and (a.CFrame.p.X+a.Size.X/2 >= b.CFrame.p.X-b.Size.X/2) and
(a.CFrame.p.Y-a.Size.Y/2 <= b.CFrame.p.Y+b.Size.Y/2) and (a.CFrame.p.Y+a.Size.Y/2 >= b.CFrame.p.Y-b.Size.Y/2) and
(a.CFrame.p.Z-a.Size.Z/2 <= b.CFrame.p.Z+b.Size.Y/2) and (a.CFrame.p.Z+a.Size.Z/2 >= b.CFrame.p.Z-b.Size.Z/2)
Check out the file with my configurations. Just figured out it only works with cubes as mentioned in the title. I was aware of EgoMoose’s Rotated Region3 modules but I’m trying to find an alternative without using Region3, but I will check it out.
I have made a weapon by welding a part to the RightHand of the character and yielded the Touched event to it. (Everything on the server) However, occasionally but somewhat regularly, the event stops triggering or does not trigger at all even though it is hitting the dummy and its hitbox which I made to try resolve this issue.