I am coding this system and ive been stuck for a while.
My code aims to have 3 lines. One forward, one left and one right. Where the left and right are coming out at a dot product angle. As seen in screenshot one.
The issue is in screenshot 2, I have the extra dimension of flight now in the game and my left and right lines always have their x rotation face the global Y axis. When they are all meant to originate from the same point like the second screenshot and act like the forward line but rotated by theta. or -theta (math.acos(dotFovRange)). If you could help at all that would be amazing
Below are my two functions, I use lineA.lookvector and lineB.lookvector to get the direction used in the create_telegraph_parts and my origin cframe is the character
function module.get_cframes_for_liness(cframe, dotFovRange, fovLength, rotationAxis)
rotationAxis = rotationAxis or Vector3.yAxis
dotFovRange = math.clamp(dotFovRange, -1, 1)
fovLength = math.max(fovLength or 1, 0) * 0.5
local theta = math.acos(dotFovRange)
local lineA = (cframe * CFrame.Angles(0, theta, 0))
local lineB = (cframe * CFrame.Angles(0, -theta, 0))
return lineA, lineB
end
local function create_telegraph_parts(originCFrame: CFrame, direction: Vector3, length: number, height: number)
local rayPart = Instance.new("Part")
rayPart.Anchored = true
rayPart.CanCollide = false
rayPart.Size = Vector3.new(1, height, (direction * length).Magnitude)
rayPart.CFrame = CFrame.new(originCFrame.Position, originCFrame.Position + direction) * CFrame.new(0, 0, -rayPart.Size.Z / 2)
rayPart.Color = Color3.new(0.85005, 0.196902, 0.157092)
rayPart.Transparency = 0.3
rayPart.Material = Enum.Material.SmoothPlastic
rayPart.Parent = telegraphsFolder
return rayPart
end