What I’m talking about:
How would I make a function that generates one of these between two points? I’ve tried googling ways to do this but I can’t find any good resources for how to make something like this.
What I’m talking about:
How would I make a function that generates one of these between two points? I’ve tried googling ways to do this but I can’t find any good resources for how to make something like this.
I’m guessing a SpringConstraint isn’t sufficient for your specific needs?
this is actually really easy:
local radius = 10
local e = 0
for i=1, 100 do
e += 1
p=Instance.new("Part", workspace)
p.Size = Vector3.new(1, 1, 1)
p.CFrame = CFrame.new(0, 10, 0) + Vector3.new(math.sin(e) * radius, math.cos(e) * radius, e)
game.Debris:AddItem(p, 3)
end
That creates more of a helix than a coil. I also need help with getting the size and rotation of parts to make it look more like a coil.
It is not, I need it for effect stuff which needs more effects then a SpringConstraint can support.
If you understand all the maths then there’s an answer on StackOverflow relating to this:
I don’t (I’m really bad at maths), and so I’d probably go about using CFrames to rotate a cylinder around a central point, and moving it up the axis until it reached the end (calculating the current and next point in order to ensure it faces the right direction).
ok i got it perfect:
local radius = 5
local e = 0
for i=1, 1000 do
e += 0.1
local p = Instance.new("Part", workspace)
p.Size = Vector3.new(1, 1, 1)
p.CFrame = CFrame.new(0, 10, 0) + Vector3.new(math.sin(e) * radius, math.cos(e) * radius, e)
end
Almost would work, but any idea on how I could have it so that the parts are rotated to connect to each other instead of there just being more parts to create a more smoother shape? Also, how would I have that go between a start point and an end point?
the start cframe is easy, but i cant tell you right now exactly how you will do the end point, the calculation will involve some .Magnitude calcs and division of the e variable based on the magnitude.
local startCFrame = CFrame.new(0, 10, 0) -- this can be done easily
local radius = 5
local e = 0
for i=1, 1000 do
e += 0.1
local p = Instance.new("Part", workspace)
p.Size = Vector3.new(1, 1, 1)
p.CFrame = startCFrame + Vector3.new(math.sin(e) * radius, math.cos(e) * radius, e)
end
Any idea how I could have the parts making up the coil connect to each other like this so it looks more smoother and uses less parts? Also how would I rotate it so it goes in a direction towards an endpoint?
you have to mess with the incriments of the e and radius variable and the parts size until you find something you like, and for the direction, use (EndCFrame.p - StartCFrame.p).Unit, and finally, take into account what i said in my last post to you about the magnitude.