So I am REALLY new to UI Vectors, and I am trying to tween a ViewPortFrame to close just like a retro window would. My problem is:
It is not how I want it to close. You know it too.
My code:
local SizeEnd1 = UDim2.new(0.335,0,0.002,0)
local SizeEnd2 = UDim2.new(0, 0,0.002, 0)
local PosEnd = UDim2.new(0.321, 0,0.229, 0)
wait(20)
script.Parent:TweenSizeAndPosition(SizeEnd1, PosEnd, Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, 0.2)
wait(0.4)
script.Parent:TweenSizeAndPosition(SizeEnd2,PosEnd, Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, 0.2)
PosEnd
is the frame’s current position.
You need to remove UI Corner i guess. You can do it in script.
No, the UICorner is not my problem, the tween is.
I want it to make the tween at the same position, but it’s moving.
Can you show us an example of what you want? (video)
ezekieltem
(Not_ezekieltem)
June 18, 2021, 3:16pm
#6
Set the anchorpoint of the UI and reposition the UI then try it again
Well that works but what is the Vector I should use? I have tried Vector2.new(0.5, 0.5)
but it is not in the middle
ezekieltem
(Not_ezekieltem)
June 18, 2021, 3:21pm
#8
UIs dont use Vector2
they use UDim2
. Try doing UDim2.new(.5,0,.5,0)
It worked with Vectors too. Just as DevHub says. But what’s the middle point ?
ezekieltem
(Not_ezekieltem)
June 18, 2021, 3:23pm
#10
if you were to use UDim2 with .5 as the scale for both X and Y it would get the exact middle point of the UI and i wouldnt know how to do it with Vectors as i never use Vectors with UI you could also use UDim2.FromScale
Getting an error, I knew it…
Players.octav20071.PlayerGui.SurfaceGui.ViewportFrame.Script:6: invalid argument #3 (Vector2 expected, got UDim2)
ezekieltem
(Not_ezekieltem)
June 18, 2021, 3:26pm
#12
hm. let me go do some testing with Vector2 to see if i can help you
1 Like
ezekieltem
(Not_ezekieltem)
June 18, 2021, 3:28pm
#13
octav20071:
Vector2.new(0.5, 0.5)
use that for the AnchorPoint
but for the position of the UI do UDim2.new(.5,0,.5,0)
The feedback was the UI sliding to the right and closing. Nope.
I have changed it with the TweenSize function, but the thing is, the anchor point!
ezekieltem
(Not_ezekieltem)
June 18, 2021, 3:34pm
#15
Question. Is the UI precreated in studio or created midgame
It is created in studio. Setting the anchor point to 0,0 in script doesn’t change anything
ezekieltem
(Not_ezekieltem)
June 18, 2021, 3:35pm
#17
you need to set the anchor point to .5,.5 and the anchor point will change to the middle of the UI object and then change the position to .5,0,.5,0 so it will go to the middle of the UI object it is parented to
I mean, that works 50%, the frame spawns in other direction than the one needed, but tweens how it should… Maybe it’s the anchor point?
ezekieltem
(Not_ezekieltem)
June 18, 2021, 3:43pm
#19
You want the one on the RIGHT correct?
Yes, yes! I want that one! How could I achieve it?