I have an issue with hoverboard that I want to just be able to fly around smoothly, however it can get stuck in things, flung into the air and become infinitely stuck
function HoverboardController:Update()
if not self.Board then return end
local Character = Player.Character
if not Character then return end
Params.FilterDescendantsInstances = {self.Board, Character}
local Raycast = workspace:Raycast(
self.Board.Position,
self.Board.CFrame.UpVector * -1000,
Params
)
if not Raycast then return end
local Part = Raycast.Instance
local GroundY = Part.Position.Y + (Part.Size.Y / 2)
self.Board.BodyPosition.Position = Vector3.new(
self.Board.Position.X,
GroundY + 3,
self.Board.Position.Z
) + (self.Board.CFrame.RightVector * self.Movement.Value)
self.Board.BodyGyro.CFrame = self.Board.CFrame * CFrame.Angles(0, self.Rotation.Value, 0)
Character.HumanoidRootPart.Velocity = Vector3.new()
end
Try this? (Im not sure if it works)
I changed the GroundY to get the actual position of the raycast
function HoverboardController:Update()
if not self.Board then return end
local Character = Player.Character
if not Character then return end
Params.FilterDescendantsInstances = {self.Board, Character}
local Raycast = workspace:Raycast(
self.Board.Position,
self.Board.CFrame.UpVector * -1000,
Params
)
if not Raycast then return end
local Part = Raycast.Instance
local GroundY = Raycast.Position
self.Board.BodyPosition.Position = Vector3.new(
self.Board.Position.X,
GroundY + 3,
self.Board.Position.Z
) + (self.Board.CFrame.RightVector * self.Movement.Value)
self.Board.BodyGyro.CFrame = self.Board.CFrame * CFrame.Angles(0, self.Rotation.Value, 0)
Character.HumanoidRootPart.Velocity = Vector3.new()
end
I think you are raycasting from the middle of the board and it is not detecting the change in elevation right away. You could place two parts in the back and front of the hover board to use for raycasting instead of the middle. When the player is using the s key you raycast from the back part and when they are pressing w, you raycast from the front part
And I believe that adding two separate methods of moving it instead of how this is done, possibly with VectorForces on the front and back could make it more realistic.