Why is this hover car acting strangely?

I have a hover-car, and whenever you touch the hover-car it starts bouncing around, and acting strangely.

Here is a model:

I did not make the thrusters. I took it from a different free model that I have âboughtâ into my inventory If you need me to show a video of what is wrong with the hover-car I will gladly put it in this topic (If kindly asked)

*Here is a video:

1 Like

You are trying to create a hover car using thrusters, no wonder itâs unstable. The reason why they are often used in cars is because the contact between the wheels and the ground keeps the entire model from flying away.
If you want to create a hover car, Iâd suggest using a body position for everything and casting a ray every frame to check if there is ground within a distance under the model. If itâs on the ground, then move the car along the plane at a predetermined distance from it; otherwise, take the last direction and apply gravity to it. Finally, increment the position using the velocity.

1 Like

So I could use a body position to fix the issue?

Body positions keep objects in place, so there is no way your car will go wild on you. But youâll have to deal a bit more with scripted physics.

1 Like

So if I have a body position, how will I make the hovercar move? (I am assuming you use velocities?)

Ok I think I understand it now, so basicly your are telling me to use bodypositions instead of bodythrusts.
But what would be the formula for calculating the force, position, ETCâŚ

You store your current velocity (initially (0,0,0)) and increment it along the plane, together with a unit vector (the direction you want the car to move along).
You apply an acceleration when the player wants to move, set it to 0 when the played decelerates. Then you take the acceleration, the result Vector3 from the plane and direction and increment it by how much time passed since the last update. In case there is nothing below, add gravity to the Y component.

Forgot to say that you need to offset the position from the plane.

1 Like

My hover car Suspension uses Thrusters and they are great, because if you donât use BodyThrusters, then you wonât have this tilt you can see in this video.

HoverCar needs slide down on slope and realistically it should tilt a bit, I donât think tilt on my hover car is enough, but if no thrusters there wonât be any tilt.

2 Likes

Having a predetermined position is much stabler than applying force to an object. The tilt is achieved through what I pointed out earlier, casting a ray downwards to check if there is anything below will give you the perfect tilt for your current terrain. Casting multiple rays to determine a mean plane between the hit points will give you even better results.

2 Likes

Iâm casting ray from every thruster at the edges. My point was that it says here BodyThrust | Documentation - Roblox Creator Hub, that-âIt behaves similar to a BodyForce , except that this objectâs force applies at a specific point ( BodyThrust.Location ), allowing you to exert a torque (rotational force)â- this causes tilt, since I have thrusters in every corner of the car

Would be interesting to see what happens if you go over a ramp. It would probably end up flipping and getting permanently stuck, or itâll just go berserk all over the map.

Do you use bodyposition to stabalize it?

How do you stabilize it (Unless you donât and you were just showing off your suspension)?

No it doesnât flip or get permanently stuck, but if height difference between thruster and raycasted part_hit is really high then it does some horrible things , but this can be easily solved with if conditional.

1 Like

What do you put in the if statement?

He sets the force to a reasonable value.

1 Like

How would he or you calculate the force? Is there some kindof math formula someone could show me? Instead of showing me an article on wikipedia or something.

Well, if height difference is really high, then you can just turn of the thruster which came across that difference and let gravity work

1 Like

Without looking too deeply it looks like you are basing the thruster force on how far off the ground the hover car is. While this is a way to approach it, you quickly realise instabilities like this happen. The main reason is you have no dampening of forces. If a corner gets close to the floor it pushes more force through to push it back up, but when it gets to the hover position it already has quite a lot of vertical velocity so will easily fly past it. You need a method to dampen the velocity so it comes to rest at the hover position.

Typically something like a PID controller (a method of combining proportional, integral and derivative factors/feedback to form a stable system) is used to achieve this which seems somewhat complicated but is surprisingly easy. However this functionality is already built into some Roblox objects!

If you use an AlignPosition you will notice that it doesnât overshoot its target (unless you are over constraining or using really high velocities). It does these dampening calculations behind the scenes for you to make them really easy to use. I would recommend you use an AlignPosition on each corner of the hover car.

The hard part here is deciding where you want each corner of the car to float. To determine this Iâd recommend you raycast down from each corner and place the AlignPositionâs target a set distance âaboveâ the spot hit. Here you can decided what above really means too. If you want the hover car to sit still on a slope then you would want above to be vertically up against gravity. If you want the hover car to slide down a slope then you want above to be the normal of the surface it hits. Here is a diagram to help understand this.

The âspringynessâ of the hover can be adjusted by changing the max force, max velocity and responsiveness, however I would say that responsiveness is the most important property here as long as the max force/velocity is high enough.

Finally the overall movement of the hover car can be done with another AlignPosition acting at the centre of mass which has a higher force than the others. This will push the hover car to the spot you want it while the corners handle how it is oriented.

Hope this clarifies how this can be approached.

5 Likes

But how would you set align positions target? it only aligns position of attachment 1 and 2 not the positions. Should he spawn part and then attach align position to it? thatâs nonsense

1 Like

One attachment for the corner of the hover car, another for where its hover target should be.

1 Like