用绳索约束连接网格

时间:2016-08-25 13:03:10

标签: lua constraints roblox cloth-simulation

我试图做一种"布料模拟"通过使用ROBLOX的新绳索约束和零件网格。

目前,我已经制作了一个10x10网格的.4x.4x.4块,现在我想用绳索限制连接每一个。

我在行和列之后命名了网格中的每个部分(例如:网格中的第一部分是1 1,最后一部分是10 10)

然后我使用它们的名称和字符串操作来获取每个单独网格部分周围的部分。

然后,我将4个附件插入每个部分和4个绳索约束。 这是代码(ab代表上面,代表下面等):

for i2 = 1, #gParts do
    local ab = tostring(tonumber(gParts[i2].Name:match("^(%S+)"))-5).."     "..tostring(tonumber(string.sub(gParts[i2].Name,-1))-1)
    local be = tostring(tonumber(gParts[i2].Name:match("^(%S+)"))+5).."     "..tostring(tonumber(string.sub(gParts[i2].Name,-1))+1)
    local le = tostring(tonumber(gParts[i2].Name:match("^(%S+)"))-1).."     "..tostring(tonumber(string.sub(gParts[i2].Name,-1)))
    local ri = tostring(tonumber(gParts[i2].Name:match("^(%S+)"))+1).."     "..tostring(tonumber(string.sub(gParts[i2].Name,-1)))
    for i3 = 1, 4 do    
        local atchm = Instance.new("Attachment",gParts[i2])
        local ropeconst = Instance.new("RopeConstraint",gParts[i2])
    end
end

绳索约束有两个我需要使用的主要属性;附件1和附件2.

1 个答案:

答案 0 :(得分:0)

我从来没有真正搞过新约束,但我相信这应该有用。

请记住,约束是Roblox中的新实例,并且它们可能仍然是实验性的。

window.onPageShow()

如果这不适合你,请告诉我。如果需要,我可以从网站上与您联系。