Raycast between two areas or on a surface?

I’m doing something that requires raycasts for collision. I want to know how I could cast multiple rays along a surface or between two positions.
If it helps my current raycasts are working fine, it’s just that right now I only have them casting from the corners of the block.
I’m grabbing the corners through this:

local c1 = Vector3.new(charcol.Position.X - charcol.Size.X/2, charcol.Position.Y + charcol.Size.Y/2) -- top left
local c2 = Vector3.new(charcol.Position.X + charcol.Size.X/2, charcol.Position.Y + charcol.Size.Y/2) -- top right
local c3 =  Vector3.new(charcol.Position.X - charcol.Size.X/2, charcol.Position.Y - charcol.Size.Y/2) -- bottom left
local c4 = Vector3.new(charcol.Position.X + charcol.Size.X/2, charcol.Position.Y - charcol.Size.Y/2)  -- bottom right

I don’t think there’s a way to get specific locations of a face of a part, especially for parts with more complex geometries. In the meantime, check out this thread on Fibonacci spheres:

Also, I’m sure you could just use spatial queries for your collision system instead, it would be much simpler and perhaps more performant than running hundreds of raycasts

3 Likes