Hello everyone, I was just wondering if there was a way that you could maintain the same position for a part when negating it into a union through UnionAsync. It’s terribly annoying because when I negate a part I don’t know what position to set it to make it the same as before. Does anyone know a formula that allows the negated part to maintain its original position? Or a way around this? Thank you.
Get the part’s position before negating it then after doing UnionAsync set the position to the original position.
I think I have. This is what I have so far:
local aPart = firstPart:WaitForChild("Thing", true)
local bPart = aPart:SubtractAsync({part})
bPart.Position = aPart.Position
bPart.Parent = firstPart
bPart.Name = "Thing 2"
part:Destroy()
aPart:Destroy()
I think I did what you said already but it’s still not working? Thanks.
Also, it’s the same position after negating but it still looks not like what I desired and shifts itself from its “original” position.
Try this:
local aPart = firstPart:WaitForChild("Thing", true)
local aPartPos = aPart.Position
local bPart = aPart:SubtractAsync({part})
bPart.Position = aPartPos
bPart.Parent = firstPart
bPart.Name = "Thing 2"
part:Destroy()
aPart:Destroy()
Thanks but it doesn’t seem to work. What is actually happening is that when I negate it into a union, it gets smaller but instead of staying in the same position it shrinks and puts itself in the centre of the position before it was negated. I don’t know how to work around this but there must be a formula or something out there. Maybe toWorldSpace would help?
when it gets smaller it’s size changes which also affects the position of the part. So I don’t think there is a work around for this.
The frustrating part is that its relative when you negate a part using tools in Studio so there must be a mathematical formula out there that could explain it. But I will keep trying, thanks for the help.
Try using CFrame to position the part
Still doesn’t work. The thing is that when you use SubtractAsync on a part for the first time, it negates fine and the location doesn’t change. It’s only when you try to use this a second time that the part starts shifting itself into weird locations relative to its previous union location. Unfortunately I need to union more than once so although it is an uncommon problem it is quite annoying. Thanks for the insights, I might just try to figure out the math for this.
Before deleting the first part, get its position then find the difference between that and your new union and that will give you the offset, then whenever setting the position of your part add that offset to it.
local Original = script.Parent
local Negative = Original.Part
local Union = Original:SubtractAsync({Negative})
Union.Parent = workspace
local offset = Union.Position - Original.Position
Union.Position = Original.Position + offset
Negative:Destroy()
Original:Destroy()
I edited yours slightly but this is what i have now and it retains its original position