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
Functions
new
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
(
deltaTime:
number
,
speed:
number
,
hoverAmplitude:
number
) →
(
)
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
(
x:
number?
,
y:
number?
,
z:
number?
) →
(
)
Sets the forces of the hover object to x
, y
and z
.
vector
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.