Stabilizing Hover

Yep. I just erased the entire script since I wanted to turn it into something usable. I managed to find the backed up version.

2 Likes

Well I think we have a solution, @VineyardVine. I think @nooneisback just remade your whole suspension system the right way!

3 Likes

What are the motor6D’s for, and can I turn the wheels to cylinders for cars?

1 Like

Motor6D’s are basically the same as Welds, but they are favored for some reason and much less likely to be deprecated. You can probably make them spin by changing the C1, though I really don’t want to deal with that right now. Welds are confusing without a sheet of paper and an hour of thinking.

2 Likes

How do you change the height of the suspension on:

1 Like

There is a config module inside the script which contains the properties. Change the Spring.MaxLength. I don’t know if it’ll change the height of the wheels though, since I welded them manually after writing the base of the script.

1 Like

It does change the height of the wheels.

How can I fix it?

1 Like

Fix it in what way? The wheels are updated per Heartbeat according to the distance of the hitpoint/spring length (if no surface below) and offset back by their radius.

2 Likes

But when I change the Spring.MaxLength in the Modulescript, the wheels are lifted above the ground as well. So the wheels will never be touching the ground. (Change the MaxLength to 10, and you will see what will happen)

2 Likes

Alright, that’s what I feared.
In the function connected to the Heartbeat, there is a segment of code that is something in the lines of “Wheel.Weld.C1”. Change it to Wheel.Weld.C0 = CFrame.new(0,-dist+whrad,0).

2 Likes

Is it at line 67?

30Characters

1 Like

To make them spin, you’ll have to turn velocity of the wheels that touch the ground into angular velocity and multiply by dt.

if Pc then
   Wheel.Weld.C0 = Wheel.Weld.C0 * CFrame.Angles(root.Velocity:Dot(nlv)*whrad*dt,0,0)
end

Not sure if it’s correct, but should be.

Place it after the height update.

3 Likes

Don’t have the place open RN, so I’ll have to tell you probably.

2 Likes

I fixed the issue and it is now:

whdyndata[2].Motor6D.C1 = CFrame.new(0,-dist+whrad + 3,0)

at line 67

The only problem that it has now is when a wheel is above the ground, it will go back up to the thruster.

2 Likes

I uploaded a fixed version. The only concern I have is how to balance the stiffness and vehicle mass. Too much stiffness makes the car unstable, not enough makes it wobble around when a player is standing on it.

2 Likes

Is there a math equation that we can use to determine the right stiffness then?

Just out of curiosity

1 Like

Hooke’s law is an equation to calculate the force exerted by the spring in case of an offset.
F=k*x
Weight is an action force that a body of a defined mass applies to a surface it is on.
F=m*g
You can calculate the minimum stiffness by checking the case where both forces are equal and stay at a fixed offset.
k*x = m*g -> k = m*g/x

Now you just add the stiffness until you get a perfectly stable vehicle under load.

The only issue is that everything is calculated in studs instead of meters, so you might get some absurd results. NVM, the results are crazily off.

2 Likes

I have had to deal with this a lot in the past year or so, I have open sourced the file I managed to successfully do this with and I can post a link here once I have access to a computer if interested.

4 Likes

DT stands for delta which means the difference in two values(Change) in this case, Time.

The wait function returns exactly how long it waited for. So the code would look something like this

function wait(Time)
    local StartTime = tick();
    --Yielding Code
    return tick() - StartTime;
end

The wait value takes a hefty majority of the computing time to the point where everything else happening in the loop is insignificant. So if the wait returns the significant difference between the time of the loop was last calculated then it’s safe to use it as the Delta value. The difference between using the Delta value supplied by Heartbeat or RenderStepped is how often it runs and, in this case, slightly more accurate timing.

3 Likes

It also eliminates the need for calling tick() on each frame.

3 Likes