So I am creating an RCL gun system, but I ran into an issue with raycasting. Sometimes, the rays will go directly through the part and not register it even exists. An example of this can be seen here.
If anyone knows how to fix this please let me know!
My code for raycasting:
func.Raycast = function(origin,endpoint,ignoreList)
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = ignoreList
params.IgnoreWater = true
local cast = workspace:Raycast(origin,endpoint-origin,params)
return cast
end
And by the way, the second argument for :Raycast() shouldve been (endpoint - origin).Unit multiplied by how far you want the script to detect it (like how many studs away from the origin)
I think it was supposed to detect the distance between the two points but as I said before, it shouldve been made with Unit since it needs a unit direction to work as intended.
I’ve changed it to unit and the issue is still happening. Also, the origin is the position of the blue block and the endpoint is the mouse’s hit position.
Yeah but I don’t really like to assume sometimes we do things out of consciousness. Endpoint might have already been solved by (destination-origin).Unit