2016-08-25 3 views
0

ROBLOX의 새로운 로프 제약 조건과 부품 그리드를 사용하여 일종의 "옷감 시뮬레이션"을 만들려고합니다.로프 제약 조건을 사용하여 그리드 연결

현재 10x10 격자의 .4x4x.4 블록을 만들었으므로 이제는 각각을 로프 제약 조건과 연결하려고합니다.

는 나는 자신의 행과 열 후 그리드의 각 부분이라는 것 (예 : 그리드의 첫 번째 부분은 10 10 인 1 일, 마지막 인)

다음 내가 각각의 격자 주위에 부품을 얻을 부분은 이름과 문자열 조작을 사용합니다.

그런 다음 각 부품에 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 

로프 제약 내가 사용할 필요가 2 개 주 속성이 있습니다; 첨부 1 및 첨부 2를 참조하십시오.

답변

0

필자는 새로운 제약 조건을 실제로 혼란에 빠뜨리지는 않았지만 이것이 올바르게 작동해야한다고 생각합니다.

제약 조건은 Roblox의 새로운 인스턴스이며 여전히 실험 가능성이 있음을 명심하십시오.

X = 10; 
Y = 10; 
spread = 4; 
--Spread is the Length of the Constraint. You may have to increase this, especially if it's stiff. 

function createAttachments() 
    --This is under the assumption that gParts is a table filled with the Part Instances 
    for i,v in pairs(gParts) do 
     local atch = Instance.new("Attachment",v); 
    end; 
end; 

function connectConstraints(part,x,y) 
    if x ~= X then 
     connectRight = x+1.." "..y; 
    end; 
    if y ~= Y then 
     connectDown = x.." "..y+1; 
    end; 
    if connectRight ~= nil then 
     local ropeconst = Instance.new("RopeConstraint",part); 
     ropeconst.Length = spread; 
     ropeconst.Attachment0 = part.Attachment; 
     ropeconst.Attachment1 = connectRight.Attachment; 
    end; 
    if connectLeft ~= nil then 
     local ropeconst = Instance.new("RopeConstraint",part); 
     ropeconst.Length = spread; 
     ropeconst.Attachment0 = part.Attachment; 
     ropeconst.Attachment1 = connectLeft.Attachment; 
    end 
end 

createAttachments(); 
connectConstraints(); 

이 방법이 효과가 없다면 알려 주시기 바랍니다. 필요한 경우 사이트 자체에서 연락 할 수 있습니다.

+0

나는 편집하기 위해 꽤 많이 편집해야했지만; 실제로 작동합니다! 고맙습니다! – Ducktor

+0

도움이 된 것을 기쁘게 생각합니다. 오류가 발생했다면 사과드립니다. 잠시 동안 Roblox에 영향을주지 않았습니다. –

+0

아, connectConstraints가 작동하도록 gPart를 살펴 봐야한다고 생각하지 않았습니다. 나는 그것에 대해 대단히 유감 스럽다. –

관련 문제