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