Hi Developers.
In this wiki document it talks about creating triangles.
I am wondering how the author was able to get the functionality shown below, as I can’t find the code on that wiki page.
Kind regards,
SerClockwerk
Hi Developers.
In this wiki document it talks about creating triangles.
I am wondering how the author was able to get the functionality shown below, as I can’t find the code on that wiki page.
Kind regards,
SerClockwerk
You can modify the function so that it takes two parameters:
function drawTriangle(a, b, c, parent, w1, w2)
And then modify the end of the code on that page as such:
(...)
-- put it all together by creating the wedges
if not w1 then
w1 = wedge:Clone();
end
if not w2 then
w2 = wedge:Clone()
end
w1.Size = Vector3.new(0.2, s1.y, s1.x)
w2.Size = Vector3.new(0.2, s2.y, s2.x)
w1.CFrame = cf1
w2.CFrame = cf2
w1.Parent = parent
w2.Parent = parent
return w1, w2
end
Then to create the triangle, you’d call:
local w1, w2 = drawTriangle(a, b, c, parent)
And to update it when a,b,c changes:
drawTriangle(a2, b2, c2, parent, w1, w2)
That’s just one way to accomplish it. (PS: I didn’t test the code in this post, if there are any minor errors you should be able to find any mistakes and fix them yourself)
Thanks!
Would this be the least intensive ways to do it?
I plan on converting this to triangles.
https://i.gyazo.com/5436f3c34a4e984e251c46ec5383e4e9.mp4
There will be a chunk render system implemented, but still want it to be optimized as much as possible.
Uh, that’s going to be an expensive operation no matter what you do really.
Don’t create and destroy the wedges on each frame, rather make sure you keep recycling the wedges that you’re using to show the effect. Moving parts in and out of the Workspace is expensive, especially when you’re trying to do it at 60 FPS.
Triangles only need a few dot and cross products; there’s no need to sort a table or use any trig. That article isn’t a good role model.
This is exactly what I was after; thank you very much!
Will reply later with what I end up with
Hey, I tried this, and I noticed a few things. First off, the triangles did not move around correctly, they glitched around. Second, how did you get it so you can make that many triangles? I checked out the code, and it took a while just to get one triangle. Could you please share how you did that?
I am a noob scripter, sorry.
You will need to speak with @Siren10 to find out how it was done.