Skip to main content

AccelTween

Provides a means to, with both a continuous position and velocity, accelerate from its current position to a target position in minimum time given a maximum acceleration. See Spring for another version of this.

Author: TreyReynolds/AxisAngles

Functions

new

AccelTween.new(
maxaccelnumber?--

The maximum acceleration applied to reach its target. Defaults to 1

) → AccelTween

Constructs a new AccelTween.

local accelTween = AccelTween.new(30)
accelTween.t = 1

conn = RunService.RenderStepped:Connect(function()
	print(accelTween.p)
end)
task.delay(accelTween.rtime, function()
	conn:Disconnect()
end)

SetClock

AccelTween.SetClock(
selfAccelTween,
clock() → number
) → ()

Sets the clock the tween reads time from. Defaults to os.clock.

Safe to call mid-tween. The stored times are shifted onto the new clock's timebase, so the current position, velocity, and the time left all carry over exactly -- the tween neither jumps nor restarts.

GetClock

AccelTween.GetClock(selfAccelTween) → () → number

Gets the clock the tween reads time from.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Constructs a new AccelTween.\n\n```lua\nlocal accelTween = AccelTween.new(30)\naccelTween.t = 1\n\nconn = RunService.RenderStepped:Connect(function()\n\tprint(accelTween.p)\nend)\ntask.delay(accelTween.rtime, function()\n\tconn:Disconnect()\nend)\n```",
            "params": [
                {
                    "name": "maxaccel",
                    "desc": "The maximum acceleration applied to reach its target. Defaults to 1",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "AccelTween"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 89,
                "path": "src/acceltween/src/Shared/AccelTween.lua"
            }
        },
        {
            "name": "SetClock",
            "desc": "Sets the clock the tween reads time from. Defaults to `os.clock`.\n\nSafe to call mid-tween. The stored times are shifted onto the new clock's timebase, so the\ncurrent position, velocity, and the time left all carry over exactly -- the tween neither\njumps nor restarts.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "AccelTween"
                },
                {
                    "name": "clock",
                    "desc": "",
                    "lua_type": "() -> number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 122,
                "path": "src/acceltween/src/Shared/AccelTween.lua"
            }
        },
        {
            "name": "GetClock",
            "desc": "Gets the clock the tween reads time from.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "AccelTween"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "() -> number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 137,
                "path": "src/acceltween/src/Shared/AccelTween.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "AccelTween",
    "desc": "Provides a means to, with both a continuous position and velocity,\naccelerate from its current position to a target position in minimum time\ngiven a maximum acceleration. See [Spring] for another version of this.\n\nAuthor: TreyReynolds/AxisAngles",
    "source": {
        "line": 10,
        "path": "src/acceltween/src/Shared/AccelTween.lua"
    }
}