Raycast ignoring Raycast parameters..?

I’ve looked through tons of DevForum posts, and have found nothing… This is my first time using raycast, am I blind and missing something, or is this a bug??

Script:

base = workspace.TestVectorBase
clone = workspace.TestVectorClone

local Laser = base.Position
local LaserDetector = clone.Position

local raycastParameters = RaycastParams.new()
raycastParameters.FilterDescendantsInstances = {game.Workspace.NodeBoundaries:GetChildren()}
raycastParameters.FilterType = Enum.RaycastFilterType.Include
raycastParameters.IgnoreWater = true

local ray = game.Workspace:Raycast(Laser, LaserDetector, raycastParameters)

if ray then
	if ray.Instance.Name == "NodeBoundary" then
		print("Hit a boundary", ray.Instance.Name)
		
		local part = Instance.new("Part")
		part.Parent = game.Workspace
		part.Anchored = true
		part.Position = ray.Position
	elseif ray.Instance.Name == "Node" then
		print("Hit a node", ray.Instance.Name)
	else
		print("Instance:", ray.Instance.Name)
	end
else
	print("This node can be used!")
end

Result 1:
Ray detects no NodeBoundary, even though 2 are in the way…


Result 2:
Ray detects NodeBoundary, even though theres none in the way…

The white surface on TestVectorBase & TestVectorClone, are surface guis that show the front face

Edit:
The selected 2 are the NodeBoundary’s in both images above
image

1 Like

:GetChildren() returns a table, you just put a table inside a table. remove the first brackets so its only one table in Filter Descendants list

raycastParameters.FilterDescendantsInstances = game.Workspace.NodeBoundaries:GetChildren()

still gives the same results

raycastParameters.FilterDescendantsInstances = {game.Workspace.NodeBoundaries}

try this.

same results

charactersssssss

I see the issue now.

The direction vector of a raycast isn’t your goal position.

get the direction by doing
Position1 - Position2 (probably switched around idk)

And multiply that by what you want as a maximum raycast distance.

2 Likes

that works, thanks :+1:

characterssss

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.