Why is the center my PartOperation broken and how can I fix it with code?

image
My PivotOffset is zero:
image
So I don’t know what could be the issue.
How could I fix it with a script?
Thanks!
brokenPartOperation.rbxm (5.5 KB)

1 Like

This is intended behaviour as noted in the docs

To fix it you could just parent the PartOperation to a model.
The model will have it’s own pivot which should be in the center.

1 Like

This doesn’t work in my case.

To make a long story short, I have this:

local mouseLocation = UserInputService:GetMouseLocation()
local unitRay = camera:ViewportPointToRay(mouseLocation.X, mouseLocation.Y)
local cast = workspace:Raycast(unitRay.Origin, unitRay.Direction * 1000, CastParams)

local target = cast.Instance

It basically sends out a ray that gives me the first part it hits. Then, I give the part rotatehandles, so that I can move it. (RotateHandles.Adornee = target)
image

Now, because the green part was the main part, it spins around the green part’s center. Putting it into a model won’t do anything because the handles spin the part itself, not the parents of the part, and not the children of the part. Thanks for the input though!

2 Likes

Temporary fix: Move a small centroid sphere to the part.ExtentsCFrame.Position of the part, and work from there. I really really don’t like this solution, so I won’t mark it, unless nothing else comes up :c

2 Likes

one way to fix that is to make the model first
then put all parts you want to union inside that model
after that add a new part make it’s size 0 and place it at the origin of that model.
Then union everything together with the small part being the main part like this.

local GeometryService = game:GetService("GeometryService")

local partA = workspace.A
local partB = workspace.B

local model = Instance.new("Model")
partA.Parent = model
partB.Parent = model

local origin = Instance.new("Part")
origin.Anchored = true
origin.Size = Vector3.zero
origin.Position = model:GetPivot().Position
origin.Parent = model

local result = GeometryService:UnionAsync(
	origin,
	{partA, partB},
	{SplitApart = false}
)

if result and result[1] then
	result[1].Parent = workspace
end

model:Destroy()
1 Like

actually forget my previous post this is a better solution.

What it does it when the union is made it parents it to a model
then it converts the union’s pivot to be in the same location as the model’s pivot
and then it gets rid of the model.

local GeometryService = game:GetService("GeometryService")

local partA = workspace.A
local partB = workspace.B

local result = GeometryService:UnionAsync(
	partA,
	{partB},
	{SplitApart = false}
)

local operation = result and result[1]

if operation then
	local model = Instance.new("Model")
	operation.Parent = model
	operation.PivotOffset = operation.CFrame:ToObjectSpace(model.WorldPivot)
	operation.Parent = workspace
	model:Destroy()
end
2 Likes

image
this doesn’t work :p

2 Likes

what can i say, it works for me.
Maybe there is another issue somewhere else.

This is my working version
Place_1.rbxl (55.9 KB)

1 Like

this one works for me. However, there is some residue left :joy:

1 Like

after you’ve unioned it, manually move it to 0,0,0 in the properties tab. the centroid is correct, but the position isn’t, and the position is what the arrows are based on.

1 Like

After some messing around, this actually isn’t the solution for someone trying to replicate the solid modeling behavior. This doesn’t work for SubtractAsync() :'c

But it still answers the post :D

2 Likes