Hovering a model: problems and solutions

How can I hover a model like in the video I saw on YouTube (link: ROBLOX Hover Car - YouTube)? I want to be able to make a model hover like in the video I saw on YouTube. I’m not sure how to make a model hover. When I try to move the model up and down with code, it just ends up moving in a straight line instead of hovering. I’ve looked for tutorials and examples online, but I haven’t been able to find anything that covers explicitly hovering a model. I also looked for solutions on DevFourm, but I couldn’t find anything that seemed relevant to my issue.

1 Like

Did you check out BRicey’s hover car tutorial?, he explained how he did it very thoroughly i recommend you check it out

I have tried implementing the approach you provided, but unfortunately, the model ended up bobbing and hovering up and down as seen in the link you provided (https://gyazo.com/2bec2766252046339712fcad960f8d27)
I would like the model to hover at a constant rate and not go up and down. Here is the source code that I used in the model

local height = 10
local range = 30
local offset_multi = 0.01

local params = RaycastParams.new()
params.FilterDescendantsInstances = { game.Workspace.Model }
params.FilterType = Enum.RaycastFilterType.Blacklist

RunService.Stepped:Connect(function()
	for _,v in ipairs(script.Parent.Engine:GetChildren()) do
		local hover = v.VectorForce 

		
		local direction = -v.CFrame.UpVector * range

		
		local result = workspace:Raycast(v.Position, direction, params)


		if result and result.Instance.CanCollide then 
			
			
			local distanceToGround = v.Position - result.Position

			
			local offset = 1 + (height - distanceToGround.Magnitude) * offset_multi 

			hover.Force = Vector3.new(-script.Parent.PrimaryPart:GetMass() * workspace.Gravity * offset  / #script.Parent.Engine:GetChildren())

		else
			hover.Force = Vector3.new(0, 0, 0)
		end 
	end
end)

What if you were to just get the current position of the object and add like 1 to the Z component and then set the new position as the goal. And if you want to tween it back down you can simply gtet the current position and subtract it by 1 and set it as the tweens goal.

1 Like

I have tried implementing the approach you provided, but unfortunately, this is the result that I am seeing https://gyazo.com/a994755662aac82e7a7dc5634f8ca751.

That is due to your tween time i believe. Try putting maybe a higher or lower number in the paramaters for tween info

Try downloading the model file that he provided in the description and take a look at how the model works

Yes, that is how I did it, I took a part of the code and rescripted it into the model.

I have tried the tweening method, It works perfectly.

Here is the code I used

--- Section 1
local Tweenservice = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(2)
local goals = {Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y + .5, script.Parent.Position.Z)}
local tween1 = Tweenservice:Create(script.Parent, tweeninfo, goals)

--- Section 2
local tweeninfo2 = TweenInfo.new(2)
local goals2 = {Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y - .5, script.Parent.Position.Z)}
local tween2 = Tweenservice:Create(script.Parent, tweeninfo2, goals2)

--- Loop
while true do
	tween1:Play()
	wait(2)
	tween2:Play()
	wait(2)
	end

@Ducky_akaDirt If you want to use my script to tween a model you should tween the primary part of the model instead fr.

Back to Top

I’ve attempted to move the model up and down using a loop code. I’ve also attempted to create a script that keeps the model’s center of mass at a certain height by moving the model up and down. None of these methods succeed.

It’s not a bug: It’s not a bug. The physics engine, in particular gravity, is causing the model to move in a straight line.

It’s not a bug. The physics engine, in particular gravity, is causing the model to move in a straight line. It’s a bug: I’ve found a bug that is causing the model to move in a straight line.

I’ve found a bug that is causing the model to move in a straight line. I need help: I need help figuring out how to make the model hover.

I need help figuring out how to make the model hover. I have a question: I have a question about hovering the model.

I have a question about hovering the model. Other: I have another issue that hasn’t been mentioned. (please explain)

Back to Top

The problem:

The model moves in a straight line instead of hovering.

The causes:

The physics engine is causing the model to move in a straight line.

The model’s center of mass is off-center.

Other:

The solution:

Create a script that keeps the model’s center of mass at a certain height.

Other:

Back to Top

The model moves in a straight line instead of hovering.

The physics engine is causing the model to move in a straight line.

The model’s center of mass is off-center.

Other:

Back to Top

Create a script that keeps the model’s center of mass at a certain height.

Other:

Back to Top

Additional questions:

Will I be able to hover the model if it has wheels?

Do you have any examples of how to hover a model?

Can I hover a model if it has a motor attached to it?

What is the best way to hover a model?

Should I use a loop or a script to