# Basic Explanation of Making Hovercar

Hey there!
So, here’s the question everyone wants to know. How do you make a hovercar in Roblox Studio. I have seen many questions about it, and even more showcases. But here’s the one thing I want to know, and hope you can help with.

How do you make a basic hovercar that rotates to the walls and ceilings, like the Innovation hovercars?

I’m not a very advanced scripter, so a basic explanation would be nice, and very helpful. I would appreciate basically a, “How Hovercars Work for Dummies” explanation, if that makes sense. Thanks for any and all help you can give me.

So I am guessing:
If your driving the hovercar, and it goes into a wall, it rotates 90 degrees so now its ‘hovering’ on the wall?

Exactly! That is what I’m going for.

Ok so I am not really good of a scripter, but I am kinda guessing this
When you hit the wal (Make a hit function) I am guessing you could use orientation to tilt it to your desire. Maybe what I am going for (Not gaurenteed to work Ill look into this):

``````YourHoverCar.Orientation = 0,0,90 -- 90 degrees
``````

Not sure if thats how you change orientation but just change the orientation whenever the part(Hover car) touches the specific part that you want it to (Floor, Walls, Roof)

That won’t work very well. You’d probably want to use BodyMovers to control the car, and a BodyGyro to change the rotation of the car smoothly, and raycast to determine when the car is approaching a wall. If the car will be able to drive on flat walls you’d probably also want to change the camera’s orientation so it looks like you’re driving on the ground and make sure the controls work the same no matter what the car’s orientation is (or the car may go down when you are trying to drive forward). I couldn’t explain the math for the life of me though haha

I’m not familiar with raycasts or body movers, or changing camera angle, for that matter. How would I do this? Any good sources that could help?

1 Like

https://developer.roblox.com/en-us/articles/BodyMover

You could probably find some posts related to hover cars or suspension cars which are similar.
This post might help:

Hello, I am working in hover motors, here are one example video:

This is part of the code:

``````self.height = 10
self.factor_height = 0
self.height = height -- distance to the ground that you want
self.mass = mass -- Mass of the model
self.need_force = workspace.Gravity * self.mass / cant -- Cant => the total engine in the model
self.power = 4 * self.height * self.mass / (cant * self.dt ^ 2)
...
-- In each motor
while true do
local vector = Vector3.new(0,0,0)
local hit, pos = workspace.FindPartOnRay(workspace, Ray.new(self.part.Position, (self.part.CFrame * CFrame.Angles(-math.pi / 2, 0, 0)).lookVector * self.height * 2))
if hit then
self.dist = (pos - self.part.Position).magnitude
local factor = self.factor_height / 100
local height = self.height * factor
local power = self.power * factor
if self.dist > 0 and self.dist < height * 2 then
local delta = self.dist - self.olddist
local force = power * (1 - self.dist  / (height - delta * 10 * factor))
vector = self.part.CFrame:VectorToObjectSpace(Vector3.new(0, self.need_force, 0)) + Vector3.new(0, force, 0)
end
self.olddist = self.dist
end
self.part.BodyThrust.Force = vector
wait()
end
...
``````
8 Likes

Did you ever finish this? And what is “self”? I don’t understand it

Self is a variable mostly used in object oriented programming. In this case, it would probably refer to the car object.

The ‘self’ instruction is used when creating classes within a module.

My class is called ClassHovercraft and I use it with different parts.

I share the code for whoever needs it.

For now I’m trying to make a game similar to terratech, where you can have parts and put them together. In this way create vehicles, etc …

Use the arrows up and down to increase the power to the engine. Then use W, A, D and S to move

Hovering4.rbxl (462,6 KB)

This is the tutorial for modules and classes: https://roblox.github.io/lua-style-guide/

Sorry, this is the link: https://www.lua.org/pil/16.1.html

Thanks a lot this will help me with my current project