Hoverboard System

I’m creating a hoverboard system and I’m trying to limit the velocity of the hoverboard. When I try and do this per axis it starts to turn because it’s reaching the max velocity on one axis and not the other. Here is the code:

velocity = Vector3.new(
	math.clamp(HoverboardController.velocity.X + velocity.X * 4, -30, 30),
	math.clamp(HoverboardController.velocity.Y + velocity.Y * 4, -30, 30),
	math.clamp(HoverboardController.velocity.Z + velocity.Z * 4, -30, 30)
)

HoverboardController.velocity is the total velocity and “velocity” is just the caculated velocity for that frame.

2 Likes

try

local Velocity = HoverboardController.velocity

if math.abs(velocity.Magnitude) > 30 then
	Velocity = Velocity.Unit * 30 -- unit takes the vector and divides it by the Magnitude so the distance will be one
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.