Raycast facing down not taking into account angle of a part

I’m trying to make a raycast face down but it needs to take into account the parts rotation. This is the script im using:

	local rayOrigin = script.Parent.Position + Vector3.new(3,0,0)
	local rayDirection = Vector3.new(0,-1,0)
	local rayLength = 50
	local raycastParams = RaycastParams.new()
	local hitPart, hitPosition = workspace:FindPartOnRayWithIgnoreList(Ray.new(rayOrigin, rayDirection * rayLength), {}, false, true)	

The ‘ray direction’ is causing the problem. I’ve tried using FromEulerAngles but that doesn’t work and causes an error. Does anyone know how to achieve this?

1 Like

Use the CFrame of the part

local direction = part.CFrame:VectorToWorldSpace(Vector3.new(0, -1, 0))
1 Like

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