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)
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.
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.
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. https://gyazo.com/2e213f7573addae25592fcb855c33c63
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.
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.
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.
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.
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.
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