I am trying to control when to reverse a tweening, preferably without another tween in order to cut down on the amount of code that I write.
So far, I’ve tried to find a way to control when a tween reverses by getting the playback progress, but as far as I can tell, there isn’t a way to do that. Here is a transcluded version of the script I was working on, going off that idea:
tweenInfo = TweenInfo.new(time, easingStyle, easingDirection, 0, true, 0) -- Only thing of note here is that the reverses property is set to true
tween = TweenService:Create(targetPart, tweenInfo, property) -- targetPart is a BasePart and property is a dictionary with the properties and values to be tweened
tween:Play()
tween:GetPropertyChangedSignal("PlaybackState"):Connect(function()
if tween.PlaybackState.Value == 0.5 then -- Did not detect when playback was halfway done as I expected it to
tween:Pause() -- Planned to use tween:Play() when I wanted it to start again
end
end)
Am I headed in the right direction with this? How should I continue?
You can’t reverse a Tween. There’s also no way to read the current alpha value (progress) of the tween. Because they’re so rigid and require so much boilerplate to use, I opt for numerical springs. I love the spr library, but flipper is also good.
Are we talking about the same “reversing”? I’m talking about the one where the tween just does what it does, then does it again backwards:
Unless I can control the progress in the springing, I don’t see how this will be useful to my problem. A quick browse through the APIs of the libraries you’ve linked show nothing obvious that I could use; I’ll dig a bit deeper though and see how I could use them…
In the meantime though, if you’re saying that this is pretty much impossible, do you reckon I should just suck it up and write the extra code?
I have sucked it up and wrote the extra code. The boilerplate wasn’t too bad, since I found out I could just reuse the same TweenInfo, but I’ll keep those other libraries in mind just in case.