General tweening API

Hi there!

I’ve encountered several issues lately with people wanting to transition properties of various instances in an easy way - all of which problems arises because it either requires developers to set up the actual updating mechanism for the transition, precision inaccuracies and so forth.

http://devforum.roblox.com/t/model-rotation-tween/28945

just to mention a few related issues.

We have a service, TweenService, which is currently only used for GUI tweening mechanisms - but adding API methods for generic tweening across any sort of instance would be useful for many people.

I suggest the following methods to be added to TweenService:

void TweenService:Tween(Instance instance, string property, variant targetValue, Enum.EasingDirection easingDirection, Enum.EasingStyle easingStyle, number duration[, function callback(Enum.TweenStatus)])

void TweenService:TweenFunc(function tweenFunction(number), Enum.EasingDirection easingDirection, Enum.EasingStyle easingStyle, number duration[, function callback(Enum.TweenStatus)])

void TweenService:Lerp(Instance instance, string property, variant targetValue, number duration[, function callback(Enum.TweenStatus)])

The given methods would be interrupted if called with the same combination of instance and property or function reference. (I’m not certain if a boolean parameter for override would be needed, as I’ve never actually used it, and don’t see anything that makes it useful)

Other than just the above issues mentioned, this suggestion would prevent further API bloat, as we already have GUIObject:TweenPosition, GUIObject:TweenSize, Camera:Interpolate (which is simply CFrame tweening with a linear easing style)

For an equivalent RBX.Lua implementation, I have this ModuleScript:
TweenUtility.rbxmx (14.4 KB)

18 Likes