Is anyone able to help me understand vehicles?

Basically what is said in the title.

I can’t get my head around how people make vehicles in their games. I’m not talking about jailbreak style quality vehicles, just small simple vehicles where the wheels don’t even move.

What I don’t understand is how the car physically moves through the workspace… Is it constraints or scripting.
Is anyone able to enlighten me slightly as to how this whole thing works?

Thanks :smile:

9 Likes

Roblox has a super simplistic vehicle system built into the VehicleSeat Object.

I’m on mobile, but the gist is to attach a vehicleSeat to a base part and attach as many wheels as you want with hinges.

You will be able to see that the wheels are detected via the HingesDetected property of the vehicleSeat.

I’ll try to find the original tutorial, but if I can’t, maybe someone else can help.

1 Like

Sorry I forgot to add…
I have tried to create a vehicle using a part, some cylinders, hinge constraints and a vehicle seat but when you get in it, it glitches and starts to fly.
I mean cars that have been scripted that feel like cars when you drive them.

I think you are referring to cars ‘where the wheels don’t even move’ as ones that use BodyVelocity to move them around as well as BodyGyro etc. and a script driven by the inputs from a VehicleSeat to control the forces.

I’ve built a lot of vehicles using the Roblox VehicleSeat and it works pretty well, but you have to tune the Torque and Speed of the car due to the wheel size, vehicle weight, MaxSpeed and TurnSpeed settings.

I’ve also messed around with tracked vehicles, and dump trucks that use weld scripts to rotate the front wheels side to side in my https://www.roblox.com/games/82472241/Construction-Site game. It still has some glitches but have fun with it! Jump in the dozer seat and out again to Anchor the tracks to reduce lag. The Front-end loader uses a system like byc14 described to rotate the center axis of the loader, but I also used a script to detect the angle of the center hinge and slow the inner wheels rotation to aid in steering.

My https://www.roblox.com/games/534616891/Track-car game uses the inputs of the VehicleSeat to command Motors (as in a normal Roblox vehicle) in the wheels driving the tracks and in the wheels in the 8 wheel drive suspension car.

Most things about suspension and steering I learned from messing around with free models on a blank baseplate to figure out how they work. Just remember to have a close look at the model to make sure there aren’t any ‘fire’ or other hazardous scripts before you run them in your place. You can learn a lot from the better free models out there.

5 Likes

Wow these are really cool.
Thanks @byc14 and @Kiansjet for your answers. I will be sure to play around with all of the suggestions

1 Like

If youre looking for cross compatible support like on my game test, you should not use vehicle seat input at all. Some of the controls are terrible, specifically for mobile and console. The joystick, for example, controls both steer and throttle. The triggers also control throttle but the input is not analog. It is mostly better to map them yourself once you got basic input handling down. You can just use values for brake and throttle based on things like the fingers position or the triggers pressure. Steering is easy on console but complicated on mobile. I had to do a lot of rotational offsets and position based angles and also check if the fingers moving the camera have not been placed on a gui. Vehicle seats are great for beginners but if you want more input control and to make a more pleasing control setup for other platforms, custom input is the way to go.

On the topic of land vehicles theres 3 main ways you can design their movement:

Sliding Vehicles

These are vehicles controlled by BodyMovers, CFrame, Force constraints, and any combination of these. A notable example are the Jailbreak vehicles. Their drifting system is god awful (cars slide across the floor like butter) but they use these methods. Another example is the freemodel Jeep from the toolbox. It is a featured freemodel. These move by manipulating forces and torque in order to push a brick car along a path. The main takeaway is that the cars have really awkward handling and the wheels do not actually spin.

Rolling Vehicles

Rolling vehicles are a step up. They use rotational constraints to get the car moving. This is pretty obviously getting more advanced but more realistic. The vehicles start to act like cars and have a more dynamic friction setup. They control differently and handle differently but one of the easiest ways to make them is to use a couple of hinge constraints and a constant torque. These do not have any suspension but most likely have steering that doesnt just change wheel direction like the older roblox vehicleseat chassis. At this point you might have more physics problems such as vibrating or glitchy wheels. At this point you might also need to lower gravity, otherwise cars fall to the floor like theyre being shoved by a huge force. (btw dont use hinges for steering)

Suspension Vehicles

These types of vehicles are typically made up of 2 constraints: cylindricals and springs. Theyre definitely a step up from rolling vehicles but come with more problems like wheel clipping, suspension explosion (poor configuration), and they are pretty hard to get right. This might require even more lowering of gravity so that they bounce more realistically. JumpPower can be reduced and body forces might also be used to give characters proper gravity. These vehicles handle a lot better and also look a lot better. They can react to bumps, stairs, and terrain correctly. They get stuck less often and have better grip on the floor. The wheels are less commonly lifted from terrain at different elevations. They do wobble at low speeds sometimes though and I couldnt get suspension types like wishbone working well. (EDIT: you can make reliable wishbone suspension systems now!)

There is one more part to vehicle simulation however:

Engineering / Simulation

Depending on how you want the car to control and how you want it to act / react, there are different ways to apply these forces and velocities. From the very basic direct setting from throttle and steer to calculating realtime engine data scaled with car size and weight. Typically, everybody should start making crappy cars with terrible handling. It is easier to see your mistakes, learn, and get better from that experience. I am not saying you should not try, I am saying try to start simple. To learn actual vehicular engineering, you would need to study several sources on how engines, transmission, and powertrains/drivetrains work. After that, it is all about implementation and calculation. The topic of making vehicles is very generic. This would be similar to asking: how do I make art? There are many different ways to do it and many different methods for different situations and different people. Also if you wish to simulate things such as RPM and gear switching, you can do it the bad way by checking forward velocity or you can do it the actual way by checking slowest and fastest spinning wheel (in rolling direction).

58 Likes

This is very detailed thank you very much :smile:

1 Like

(Sorry for delayed reply but just saw this)

how should you control steering?

I assume you use Roblox constraints heavily intertwined with your own physics calculations, can you provide examples of where this bridge happens? (e.g: for switching gears)

btw you should seriously consider making a post about this in learning resources because you will get a lot of people to religiously worship you xd

Steering should be done with something such as rotating an attachment. Physical steering is awful (at least in roblox). And there is no ‘bridge,’ it is pretty obvious once you set the car up. The constraint (for the most part) requires velocity and torque so you would set them accordingly based on things such as the engine torque and the gear and differential ratios. Since you do not have an actual engine running, you need to simulate them with backtracking and engine simulation. Since the engine powers the rear wheels directly (on RWD drivetrains), you can go backward and so on. Torque converters and clutch exist to prevent stalls (and clutch also for gear shifting).

1 Like

Cars don’t usually bounce more realistically? I mean, it did take a lot of tweaking, but my chassis bounces just fine on normal gravity. No scripted forces or body movers.

I use a PrismaticConstraint with LimitsEnabled to force the wheel to bend to my will. Here’s a snippet of the controlling script (this updates at about 60 FPS, depending on the client framerate):

local steeringAngle = 0

if hub:FindFirstChild('Steer') then
	steeringAngle = seat.SteerFloat * hub.Steer.Value
end

local angle = (steer.UpperAngle * 4 + steeringAngle) / 5

steer.LowerAngle = angle
steer.UpperAngle = angle

It’s very hard to use motors or servos because those aren’t reliable for steering…

Sorry for reviving an old thread.

4 Likes

Roblox have a simple object called a VehicleSeat. If you create one and create a part and scale the part to a size, whilst making sure it is not too big otherwise, it will not work. Weld the VehicleSeat to the top of the part and create 4 cylinders with hinges on one of the flat sides, raise up the seat and base 1 stud and place the wheels making sure the hinges are facing into the base and, BAM! You have created a simple car! Modify it to your liking! Check my profile to see my cars in ROBLOX!

3 Likes