Interesting topic!
You cant bend a part itself; however, you can create a bunch of points across a curve and then you can use parts to connect each point to the next point to create a “curve.” I believe in your ability to fill in the part between each point, there are many resources online for that, but if you get stuck on that part feel free to hit me up again and I can help with that part.
As to take care of the first part we should first generate the “keyframes.” For this I will be assuming the “equations” you are referencing will be the quadratic equations or y=ax^2 + bx + c
, if this is true I have come up with the following simple function to turn this into code:
function generateKeyframes(quad_term, linear_term, const, length, gap) -- input slope and y-intercept
local points = {}
for x=-(length/2),length/2,gap do
local y = quad_term*x^2 + linear_term*x + const
table.insert(points, {["x"]=x,["y"]=y})
end
return points
end
Parameters:
- quad_term =
ax^2
- linear_term =
bx
- constant =
c
- length = the amount of keyframes you want to have total
- gap = the increment in the x value for each keyframe
This function returns a table with the keyframes, a sample for this would look like:
{
{
["x"] = 0,
["y"] = 5,
},
{
["x"] = 1,
["y"] = 5.9,
}
}
Anyways, with these keyframes in place it is easy to generate parts across this curve:
function placeParts(partCount)
local keyframes = generateKeyframes(0.9, 0, 5, partCount, 0.5)
local count = 1
for _, keyframe in keyframes do
local part = Instance.new("Part")
part.Position = Vector3.new(keyframe.x, keyframe.y, -20)
part.Anchored = true
part.Size = Vector3.one
part.Shape = Enum.PartType.Ball
part.Name = "Part"..count
part.Parent = workspace
count += 1
end
end
Very simple function, I dont think I need to explain anything. Anyways, we can now call this function
placeParts(200) -- this will use 200 parts to display the curve
With this program in place, the results should look like this:
As briefly mentioned in the beginning, the only part missing from this would be to connect the keys here with parts to make it look like 1 curve, once again, let me know if you need more help with that.