エンジンクラス
PartOperation
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
プロパティ
方法
SubstituteGeometry(source: Instance):() |
継承されたメンバー
TriangleMeshPartから継承された3
BasePartから継承された105
PVInstanceから継承された4
Instanceから継承された57
Objectから継承された6
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