SImple: can I change an Union’s center? I need to do this in a way that when tweening the CFrame, the CFrame is not in the center
You can just offest the tweening position by some arbitrary point you define yourself.
And how is that done?
The part would only be temporary just to get the position, it is not neccessary once you figure out the offset.
And where can I see the center? Like is there a visibility toggle? It would be SO MUCH easier instead of playtesting every time.
The center of your union is it’s position.
Ohhhh
I’ll see if I can understand that, I might be back in a few days
Another way you can figure out the offset, which might be easier for you would be to insert an Attachment into your Union. Which would look like this:
You can also move that attachment to your desired center point, that way you can figure out the offset way easier, since attachment position is relative to it’s parent.
The highlighted Property would be the offset.
Where is the offset property for the first method?
Unions inherit from PVInstance, which means that you can edit their origin from the properties tab
This does mean that you’ll need to set the union’s CFrame using PivotTo instead of setting its CFrame property directly, since the CFrame property ignores the custom origin
Since you would like to tween the union’s CFrame, you’ll need to use a workaround in-order to be able to use PivotTo:
-- Example code, should work but I didn't have time to test it. Might need some modifications so that it better suits your needs
local TweenService = game:GetService("TweenService")
local TWEEN_INFO = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local union = script.Parent
local cframeValue = Instance.new("CFrameValue")
cframeValue.Value = union:GetPivot()
local function onCFrameValueChanged(value: CFrame)
union:PivotTo(value)
end
local function tweenUnionCFrame(targetCFrame: CFrame)
local connection = cframeValue.Changed:Connect(onCFrameValueChanged)
local tween = TweenService:Create(cframeValue, TWEEN_INFO, {Value = targetCFrame})
tween:Play()
tween.Completed:Wait()
connection:Disconnect()
end
tweenUnionCFrame(CFrame.new(0, 4, 8)) -- Ideally, you should use a debounce to prevent calling this function while the tween is still active
I understood nothing of that??!!?
I’m a noob. Make it so I understand pls
Since PVInstances were added, BaseParts now have a position and an origin
The simplest way I can describe how the origin works is that you should essentially treat it as an offset value for the BasePart’s actual position, so for example if you try to position a part whose origin is set to (0, 1, 0) to (0, 4, 0), the distance between the ground and the center of the part (assuming that the ground is located at (0, 0, 0)) will be 3, not 4, as it would’ve been if the part’s origin was left to the default value of (0, 0, 0)
At the moment, if you try changing the part’s origin then attempt to position/rotate/cframe it using the usual properties, they will ignore the origin value and transform the part as though its origin is set to the default of (0, 0, 0), which means that we must use GetPivot to read the part’s CFrame relative to its pivot, and PivotTo to transform the part relative to its pivot
Since GetPivot and PivotTo are methods, and therefore can’t be tweened using the traditional means, we’ll need to use a CFrameValue as a workaround
In the first method you figure out the offset with math by subtracting the Offset Position from the Union’s Position
The second method doesn’t involve math, it uses the fact that an Attachment Instance’s Position is Relative to the Parent ( The Parent is Part the Attachment is in. )
Im sorry to tell you this, but if you want to start coding you should learn basic vector math.