hello, im am trying to make this machine be filled up with inc, but i am having trouble calculating how the inc should be scaled and placed according to the progress of the completion
and it stays in the same position, only the size changes.
the snippet of code:
local extracting = true
local progress = script.Parent.Parent.Parent.Config.Progress
local extractionSpeed = char.Config.ExtractionSpeed
local extractionSpeedMultiplier = char.CharacterValues.ExtractionSpeedMultiplier
local inc = script.Parent.Parent.Parent.Venom
while extracting do
task.wait(1)
progress.Value+= extractionSpeed.Value*extractionSpeedMultiplier.Value
if progress.Value >= 100 then
progress.Value = 100
inc.Size = Vector3.new(maxIncSize, inc.Size.Y, inc.Size.Z)
break
end
TweenService:Create(inc, TweenInfo.new(1, Enum.EasingStyle.Linear), {Size = Vector3.new((progress.Value/maxIncSize) * 0.25, inc.Size.Y, inc.Size.Z)}):Play()
end
Easy, as you can see the ink is not moving, well for it to work, you need to change position in y axis to half of the size you’re changing it to, add it to your tween and you got it!
To explain a little better, let’s say you have a line in 2d diagram, there are squares, let’s call it studs. So the center position of your line is X = 2, Y = 0 studs and size is not defined. But you wish to increase the size of Y by 3 studs. And as you do, you see the line is not gaining 3 studs up, but instead it’s getting 1.5 studs on both sides, so for it to be illusion of it just rising up instead of growing in both sides, that 1.5 studs in Y behind has to be moved up back in position, so you add to your position half of the size you added which is exactly how much it grew in other side, so your Y position is 1.5