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.
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.
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.
What do you put in the if statement?
He sets the force to a reasonable value.
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
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.
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
One attachment for the corner of the hover car, another for where its hover target should be.
But can attachment be position?
It says it’s property of attachment but what should this attachment be?
I have already solved this, and anyone that wants to answer my latest question, please visit this topic: How can I detect whether or this object is on the ground?