API 참조
속성
메서드
SubstituteGeometry
매개 변수
반환
()
코드 샘플
대체 기하학 및 드롭 제약 조건
local GeometryService = game:GetService("GeometryService")
local mainPart = workspace.PurpleBlock
local otherParts = { workspace.BlueBlock }
local options = {
CollisionFidelity = Enum.CollisionFidelity.Default,
RenderFidelity = Enum.RenderFidelity.Automatic,
SplitApart = false,
}
local constraintOptions = {
tolerance = 0.1,
weldConstraintPreserve = Enum.WeldConstraintPreserve.All,
}
-- 비동기이므로 pcall()에서 유니온 작업 수행
local success, newParts = pcall(function()
return GeometryService:UnionAsync(mainPart, otherParts, options)
end)
if success and #newParts > 0 and mainPart:IsA("PartOperation") then
-- 결과 작업에서 첫 번째 파트를 대체에 사용할 파트로 설정
-- 첫 번째 파트는 단순히 옵션일 뿐; 이는 어떤 PartOperation이든 될 수 있습니다
local substitutePart = newParts[1]
-- 메인 파트의 위치로 파트 재배치
substitutePart.CFrame = mainPart.CFrame
-- 보존하거나 드롭할 제약 조건/부착물을 계산
local recommendedTable = GeometryService:CalculateConstraintsToPreserve(mainPart, newParts, constraintOptions)
-- 메인 파트의 기하학을 대체 기하학으로 대체
mainPart:SubstituteGeometry(substitutePart)
-- 대체와 함께 자동으로 보존되지 않는 제약 조건/부착물 드롭
for _, item in pairs(recommendedTable) do
if item.Attachment then
if item.ConstraintParent == nil then
item.Constraint.Parent = nil
end
if item.AttachmentParent == nil then
item.Attachment.Parent = nil
end
elseif item.WeldConstraint then
if item.Parent == nil then
item.WeldConstraint.Parent = nil
end
end
end
-- 다른 파트 파괴
for _, otherPart in pairs(otherParts) do
otherPart.Parent = nil
otherPart:Destroy()
end
end