Touchy question

so, this is most likely a dumb question but is there a way to get the point(s) or maybe some sort of vector3 a part touched another part?
If there is a way, it would be really helpful

What exactly do you mean by

vector3 a part(s) touched another part?

1 Like

Made a silly grammar mistake i meant

point(s) or maybe some sort of vector3 a part touched another part?

You mean the position where they made contact? That’s not currently possible without implementing a full headache of your own geometry math.

1 Like

Raycasting has that feature but not .Touched

1 Like

mommy said I was a smart boy I’m ready for the solution I can do geometry

I was thinking of using it but I dont know how

If you need to ask, you’re not ready.

You need to work in local space. First use part A local space and see if any of the corners of part B are inside of the bounding box of part A. Then use part B local space and see if any of the corners of part A are inside the bounding box of part B. If any corners are intersecting, you’ve got a collision. It’s not perfect but it will work if your parts aren’t going to be passing through each other. You can then take that corner and use that as the approximate contact position.

1 Like

correct mostly

  1. local space as in?
  2. how check for corners?
  3. :

how do I achieve that?

also Sorry im asking dumb questions I’m not on my prime rn

I don’t know if it works for all kinds of Parts or Mesh.

local TargetPart = workspace.A

local RP = RaycastParams.new()
RP.FilterDescendantsInstances = {TargetPart}
RP.FilterType = Enum.RaycastFilterType.Blacklist

TargetPart.Touched:Connect(function(Hit)
	local Raycast = workspace:Raycast(TargetPart.Position, Hit.Position - TargetPart.Position, RP)
	if Raycast then
		print(Raycast.Position)
	end
end)

Sources: Raycasting

To convert anything into relative space, you subtract it. 10-7 is 3, meaning that in local space 10 is 3 away from 7. This also works with Vector3s, but CFrames are matrices and so it’s slightly different. CFrames are ‘added’ through matrix multiplication, so to subtract one from the other you want to multiply A by the inverse of B. local cf = a.CFrame * b.CFrame:inverse()

You need to work with CFrames again. You need to convert the local space corners (located at half the size X, half the size Y, and half the size Z) into the local space of the other part.

Then for each corner, just check if it is inside of the walls of part A.

1 Like