Skip to main content

Hover

A simple hover class for implementing hover effects.

local hover = Hover.new(0, 1, 0)
local originalPosition = part.Position

RunService.Stepped:Connect(function(_, deltaTime)
	hover:update(deltaTime, 0.5, 1)
	part.Position = originalPosition + hover:vector()
end)

Types

Hover

type Hover = Hover

Functions

new

Hover.new(
xnumber?,
ynumber?,
znumber?
) → Hover

Constructs a new hover object, with forces x, y and z which can only be 0 and 1. These forces determine on which axis the hover effect is applied to - e.g if x is 1, then the hover effect will be applied on the X axis and if y is 1, then the hover effect will be applied on the Y axis.

NOTE

x and z will both default to 0 if not specified but y will default to 1 if not specified - which means by default, the hover effect will always be applied on the Y axis.

pause

Hover:pause() → ()

Pauses the hover effect.

resume

Hover:resume() → ()

Resumes the hover effect.

update

Hover:update(
deltaTimenumber,
speednumber,
hoverAmplitudenumber
) → ()

Updates the hover effect. deltaTime is a measure of how fast the hover effect is updated per frame, along with speed. hoverAmplitude is a measure of how much the hover effect is applied on each axis.

NOTE

If the hover effect is paused, then this method will not do anything.

setForces

Hover:setForces(
xnumber?,
ynumber?,
znumber?
) → ()

Sets the forces of the hover object to x, y and z.

vector

Hover:vector() → Vector3

Returns the vector used in implementing the actual hover effect.

NOTE

If the hover effect is paused, then this method will return Vector3.zero.

local hover = Hover.new(0, 1, 0)
local originalPosition = part.Position

RunService.Stepped:Connect(function(_, deltaTime)
	hover:update(deltaTime, 0.5, 1)
	part.Position = originalPosition + hover:vector()
end)

destroy

Hover:destroy() → ()

Destroys the hover object and renders it unusable.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": " \nConstructs a new hover object, with forces `x`, `y` and `z` which can only be `0` and `1`.\nThese forces determine on which axis the hover effect is applied to - e.g if `x` is `1`,\nthen the hover effect will be applied on the X axis and if `y` is `1`, then the hover effect\nwill be applied on the Y axis.\n\n:::note\n`x` and `z` will both default to `0` if not specified *but* `y` will default to `1` if not \nspecified - which means by default, the hover effect will always be applied on the Y axis.\n:::",
            "params": [
                {
                    "name": "x",
                    "desc": "",
                    "lua_type": "number?"
                },
                {
                    "name": "y",
                    "desc": "",
                    "lua_type": "number?"
                },
                {
                    "name": "z",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Hover\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 36,
                "path": "src/Hover/init.luau"
            }
        },
        {
            "name": "pause",
            "desc": " \nPauses the hover effect.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 52,
                "path": "src/Hover/init.luau"
            }
        },
        {
            "name": "resume",
            "desc": " \nResumes the hover effect.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 60,
                "path": "src/Hover/init.luau"
            }
        },
        {
            "name": "update",
            "desc": " \nUpdates the hover effect. `deltaTime` is a measure of how fast the hover effect\nis updated **per frame**, along with `speed`. `hoverAmplitude` is a measure of \nhow much the hover effect is applied on each axis.\n\n:::note\nIf the hover effect is paused, then this method will not do anything.\n:::",
            "params": [
                {
                    "name": "deltaTime",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "speed",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "hoverAmplitude",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 74,
                "path": "src/Hover/init.luau"
            }
        },
        {
            "name": "setForces",
            "desc": " \nSets the forces of the hover object to `x`, `y` and `z`.",
            "params": [
                {
                    "name": "x",
                    "desc": "",
                    "lua_type": "number?"
                },
                {
                    "name": "y",
                    "desc": "",
                    "lua_type": "number?"
                },
                {
                    "name": "z",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 87,
                "path": "src/Hover/init.luau"
            }
        },
        {
            "name": "vector",
            "desc": " \nReturns the vector used in implementing the actual hover effect.\n\n:::note\nIf the hover effect is paused, then this method will return `Vector3.zero`.\n:::\n\n```lua\nlocal hover = Hover.new(0, 1, 0)\nlocal originalPosition = part.Position\n\nRunService.Stepped:Connect(function(_, deltaTime)\n\thover:update(deltaTime, 0.5, 1)\n\tpart.Position = originalPosition + hover:vector()\nend)\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Vector3\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 111,
                "path": "src/Hover/init.luau"
            }
        },
        {
            "name": "destroy",
            "desc": " \nDestroys the hover object and renders it unusable.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 127,
                "path": "src/Hover/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "Hover",
            "desc": " ",
            "lua_type": "Hover",
            "source": {
                "line": 21,
                "path": "src/Hover/init.luau"
            }
        }
    ],
    "name": "Hover",
    "desc": " \n\nA simple hover class for implementing hover effects.\n\n```lua\nlocal hover = Hover.new(0, 1, 0)\nlocal originalPosition = part.Position\n\nRunService.Stepped:Connect(function(_, deltaTime)\n\thover:update(deltaTime, 0.5, 1)\n\tpart.Position = originalPosition + hover:vector()\nend)\n```",
    "source": {
        "line": 16,
        "path": "src/Hover/init.luau"
    }
}