How i can make raycast through part, like on photo?

image
I need make raycast like on photo, how i can?
(i need position of green dot)

1 Like

I dont think there is a built-in function for this. The only way i see this being done is by raycasting a second time, with the opposite look vector, positioned along the line of the first ray.

are you trying to detect the intersection points of the part, or ignore the part completely?

for the former, as maxx mentioned, you could shoot two rays, one from the start towards the part, and one in the distance coming back in the opposite direction, so you can find out where they both intersect

if its the latter, its very simple to add the part to a blacklist so it is not detected during the raycast

okay, i need 2 rays for finding intersection

i think, this gonna work, not?

local result = --our raycast
local hit = result.Hit
local instance = result.Instance
local point1 = instance.Position + instance.Size/2
local point2 = hit + point1 -- our green point
1 Like

image
almost, need change something


how do i fix position?

-- Refraction --
	if Config.Render.Refractions and (instance.Material == Enum.Material.Glass) then
		local point1 = instance.Size/2 + instance.Position/2
		local point2 = -(hit) + point1 -- our green point
		local n = Instance.new("Part")
		n.Anchored = true
		n.Position = point2
		n.Size = Vector3.new(0.5, 0.5, 0.5)
		n.Parent = workspace
	end