Is it possible to make a detection area a triangle type shape?

Im making a detection system but i want the detection shape to look like a triangle, also using raycast.

script:
local rig = script.Parent
local att1 = Instance.new(“Attachment”) – attachments are for the positions of left and right

local att2 = Instance.new(“Attachment”)

local RC = RaycastParams.new()
RC.FilterType = Enum.RaycastFilterType.Exclude
RC.FilterDescendantsInstances = {}

while wait() do
local Pos = rig.Head.Position
local Direction = rig.Head.CFrame.LookVector
local Left = rig.Head.CFrame.XVector * -5
att1.WorldPosition = Left
att1.Parent = rig.Head
local Right = rig.Head.CFrame.XVector * 5
att2.WorldPosition = Right
att2.Parent = rig.Head

local ray = workspace:Raycast(Pos,Direction * 2 + Right + Left,RC)

if ray then
	print(ray.Instance)
end

end

I tried using multiplication for the left and right vectors but that didnt work either, im not sure how to tackle it.
Example:

You cant make a raycast that bends in roblox, as far as im aware.

I see 2 possible options:

  1. You make a really big pyramid-shaped block and use workspace:GetPartsWithinPart() to figure out if anything is within the part
  2. Extremely complicated Cframe math that requires you to cast rays from the player’s eyes, rotated by an angle each time. IE cos(Angle)(TargetX - Head.X) - sin(angle)(TargetY-Head.Y) + Head.X = X, sin(angle)(TargetX - HeadX) + cos(angle)(TargetY - Head.Y)+Head.Y = Y which looks like this hell:
local Head = script.Parent
local Target= --Offset of parent, ie an attachment
local X =math.cos(math.rad(--[[This has to be an angle given by the for loop]]))*(Targe.tX - Head.X) - math.sin(math.rad(--[[The Angle from For]]))*(TargetY-Head.Y) + Head.X
local Y = math.sin(math.rad(angle))*(TargetX - HeadX) + math.cos(math.rad(angle))*(TargetY - Head.Y)+Head.Y = Y 
local NewRaycastDestination = --[[X,Y, But no Z cuz im tool lazy and this is already too complicated]]

yea… ill go with the first option.

wasnt really trying to do it that way but if its the only way then a guess i,ll have to do it

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