hello Developers,I Have Made An Range Circle Which Is Similar To The TDX Range Circle But I Have Only Done The RayCast Handling I Don’t Know How To Actually Draw It Here Is My Ray Handling Script:
local part = workspace.Target1
local RunService = game:GetService("RunService")
local numRays = 36
RunService.PostSimulation:Connect(function(deltasim)
for i = 1, numRays do
local angle = math.rad(i * (360 / numRays))
local startCFrame = part.CFrame * CFrame.Angles(0, angle, 0)
local direction = startCFrame.LookVector.Unit * 200
local RaycastResult = workspace:Raycast(part.Position, direction, nil, {part})
if RaycastResult then
local hitInstance = RaycastResult.Instance
print("Detected:", hitInstance.Name)
end
end
end)
im asking for someone to help me along with the drawing(im not asking for full scripts)
ok soo i have draw a circle but i have a few problems when i collide with the range it disappears but there is a short delay and the ray sometimes detects parts that are far away and this problem
I made this. Then used code from this to work it out
local wedge = Instance.new("WedgePart");
wedge.Anchored = true;
wedge.TopSurface = Enum.SurfaceType.Smooth;
wedge.BottomSurface = Enum.SurfaceType.Smooth;
local function draw3dTriangle(a, b, c, parent, w1, w2)
local ab, ac, bc = b - a, c - a, c - b;
local abd, acd, bcd = ab:Dot(ab), ac:Dot(ac), bc:Dot(bc);
if (abd > acd and abd > bcd) then
c, a = a, c;
elseif (acd > bcd and acd > abd) then
a, b = b, a;
end
ab, ac, bc = b - a, c - a, c - b;
local right = ac:Cross(ab).unit;
local up = bc:Cross(right).unit;
local back = bc.unit;
local height = math.abs(ab:Dot(up));
w1 = w1 or wedge:Clone();
w1.Size = Vector3.new(0, height, math.abs(ab:Dot(back)));
w1.CFrame = CFrame.fromMatrix((a + b)/2, right, up, back);
w1.Parent = parent;
w2 = w2 or edge:Clone();
w2.Size = Vector3.new(0, height, math.abs(ac:Dot(back)));
w2.CFrame = CFrame.fromMatrix((a + c)/2, -right, up, -back);
w2.Parent = parent;
return w1, w2;
end