Simulating Vehicle Turning Circle Correctly

I am currently creating a vehicle without using any of Roblox’s constraints (similar to Jailbreak). It’s going great however I am having issues getting the vehicle to turn realistically.

Given the steering angle and length of a vehicle it isn’t hard to calculate its turning circle radius and therefor the angular velocity needed to turn the vehicle at a given speed.

image
image

However in Roblox I’m struggling to apply the angular velocity in the right place.
It’s a hard problem to describe but maybe this image sums it up best.


If I use the BodyAngularVelocity object on the vehicle and apply angular velocity it will rotate from the center of the object.

However this is not how vehicles work, they pivot around the rear of the vehicle as shown in the picture on the right. This means the rear wheel doesn’t follow the path of the front wheel.

Does anyone know how to to this on Roblox? Essentially I need a way to alter the pivot point. I know this is possible to do by CFraming the object but that’s not an option. Currently I am using BodyAngularVelocity but there doesn’t seem to be any way to give this a radius or a specific position.

If you need some more clarification just ask.
I have achieved the intended effect using a hinge to turn the vehicle but this is extremely ugly, only works along a 2D plane.

7 Likes

I can’t understand squat that you said! Looks like you’re doing good though so :+1:

1 Like

Find the pivot of the rotation. In the BodyAngularVelocity, the pivot is always on the center of the object/model. You should try changing that pivot.
It’s not an easy task. In this case, the pivot might change at every step the car moves.
You’ll always be using a 2D solution for it though.
You should always have in mind that the wheels are tangent to the steering circle.
chrome_2018-05-31_14-34-28

mspaint_2018-05-31_14-37-18
That’s where i’d start.

3 Likes

The pivot of the rotation is easy to find and is described here:
image

Like you said the difficulty, hopefully not an impossibility on Roblox is trying to change the location of the pivot.
This is what I need help with.

2 Likes

I never actually solved this - I got the car rotating about the rear axel, but doing so caused it to strongly accelerate or decallerate when turning.

1 Like

If your difficulty lies in being able to change the position of the pivot, couldn’t you parent the BodyAngularVelocity to a small part, weld the part to the vehicle chassis, then adjust the weld to move the part that would act as the pivot?

Of course, this approach depends on BodyAngularVelocity objects always using the center of the parented part as the pivot, rather than the centroid of the connected (welded) model.

Could you tell me how you got it rotating around the rear axle?

I have tried that but unfortunately it seems as though it pivots around the center of mass of whatever construct it’s attached to. (So the whole vehicle)

My script might work differently, because mine did this:

  1. Find the velocity of the chassis part in object space
  2. Apply a force to make the sideways velocity 0
  3. Calculate the desired angular velocity of the vehicle based upon it’s speed
  4. Apply a torque to achieve desired angular velocity

It was simply a case of changing 1) to the velocity of the rear axle, but I could never figure out the weird speeding up/slowing down issue that resulted, so I just left it rotating around the center.

Also, remember that an object with no other forces acting on it will always rotate about it’s center of mass when a torque is applied, irrespective of the location of the torque, so you can only change the center of rotation by changing the forces acting on the car.

Did you happen to have BodyVelocity? I’ve noticed to have weird effects slowing and speeding up when rotating the object.

No, I operate my chassis entirely on BodyThrust. (Even the torque is made with BodyThrust because the constraints to make a torque didnt exist when I started it)

1 Like

Hmmm. I had to use BodyVelocity to give it the right amount of friction to stop it from sliding left to right on hills

Yeah, I still have that problem, although I’ve got a few ideas to fix it.

What if you just weld a Transparent CanCollide off Part an equal number of studs behind the rear axle as the front of the car is from the front of the axle?

This should ‘center’ the model around the rear axle.

I used Constraints on my front-end loader for my Construction site game. It steers by pivoting the entire chassis at the center. The issue I had was that the inside wheels were spinning at the same rotational speed as the outside wheels which made for unrealistic movement. I wrote up an equation that uses a constant divided by the absolute value of the steering angle which allows the inner wheels to spin slower like a differential in a car. Here’s part of that script:

if ang.CurrentAngle >6 then --(ang.CurrentAngle is the angle of the central pivot, controlled by left or right steering)
sp = 36/math.abs(ang.CurrentAngle) --(sp is the rotational speed of the inside wheels)

This won’t work unless the welded part has mass roughly equal to the car, which will then mess up the suspension and other handling characteristics.

3 Likes

So I managed to get something along the right lines working in a test. You can see it’s not perfectly circle but that seems to be down the Roblox engine not working correctly unless I’m missing something.
It uses BodyVelocity, BodyAngularVelocity and BodyThrust.

The BodyThrust pushes against the chassis to prevent the rear wheel going outside of the front wheel.
However I’m not sure how I’m going to alter this accurately at different angular velocities. I think @madattak said something about keeping the sideways velocity at the back of the vehicle at 0?

2 Likes

Well for now there doesn’t seem to be any practical way to implement this on Roblox.

As an update to this I did eventually get this working.
I decided that the best solution was to accurately model how car wheels work with friction. I apply a friction force with the correct coefficient to each ‘wheel’ in the right direction which gives me perfectly accurate friction on slopes and flat surfaces.

You can see that the back wheel is on the inside of the front wheel when turning, it’s also possible to drift the vehicle at higher speeds. The turning you see is done completely with my simulated friction.

6 Likes