Help With Making A Basic Car

  • What are you attempting to achieve? (Keep it simple and clear)
    I am attempting to make a very simple car for my game, with a pretty low amount of features.

  • What is the issue? (Keep it simple and clear - Include screenshots/videos/GIFs if possible)
    I used to use Surface Hinges, but today’s update removed those, and I don’t know how or which Constraint to use.

  • What solutions have you tried so far?
    A HingeConstraint connecting each wheel to the chassis. The chassis is then welded to a VehicleSeat. The car doesn’t move at all.

I am trying to make a very basic car for my new game. It does not need to have suspension or left-right turning front wheels. I am using a multi-part chassis welded together, with a VehicleSeat to drive it (no scripts). I used to use Surface Hinges, but they have been removed and I now do not know how to easily build cars without using free models.

This is my current chassis:
image

And here is my Workspace and one HingeConstraint’s details:

I am new to Constraints and scripting. Please no super-complicated designs.

Thank you for your help!

8 Likes

Hiwiwi, you can try this approach.

Create an empty Model
Place a Part inside the Model, its the Body of the car.
Place a VehicleSeat inside the Model, weld it to the Body
Place 4 Hinge Constraints FROM the Body to the Wheels
Rename both rear Hinges to “Hinge1” and “Hinge2
Change the ActuatorType property in both rear Hinges, set it to Motor
Set the MotorMaxTorque property to a higher value too (depends on ur car, try 10000)
Place a Script inside VehicleSeat. And try this code in it:

-- Instance ur car and seat
local seat = script.Parent
local car = seat.Parent

-- Instance ur Motor Hinges
local motor1 = car.Hinge1 -- rename "HingeConstraint" to "Hinge1" in ur car
local motor2 = car.Hinge2 -- rename the other Hinge to "Hinge2"

-- Max Speed to use
local maxSpeed = 20

-- Move car function
local function carMove(property)
	if property == "Throttle" then
	-- Changing the Speed of the Motor Hinge from 0 to the user's input
	-- Multiplied by the maxSpeed you already set
		motor1.AngularVelocity = seat.Throttle * -maxSpeed
		motor2.AngularVelocity = seat.Throttle * maxSpeed
	end
end
-- Listener, when the Driver seat get any user input, "Throttle" or "Steer" etc
seat.Changed:Connect(carMove)

if the car moves weird, there’s certain details to change, the minus symbol in seat.Throttle * -maxSpeed inside the script. Shift them from motor1 to motor2.

Implementing steering is very simple too. Hope it helps, we’re here if u have more questions :3

10 Likes

I’ll try that. Thanks for helping me. I’ve never needed to code a car, I’ve just used hinges before…

2 Likes

Thank you! The car now can move back and forth. How would I make the car turn? The car’s front wheels do not need to visually move left-right, but they can if necessary.

2 Likes

To make it turn, build a “Steer Beam” with a Hinge Constraint Servo ActuatorType, and listen the player’s input by script. Its exactly the same as u did for the motor.

Theres a lot of different ways to create steering, the most basic is a “T beam shape”. A Part that holds both front wheels, that Part spins on its axis, so both wheels change its position. That part is welded to the Body of the car by the Hinge Servo, so it can be rotated.

Like this basic car

Try any idea you have to make better cars, like using suspensions, different shapes, parts, constraints. By testing and practice.

You can listen the player’s input Steering value, form the Seat. VechileSeat sends a lot of values when a player is using it, u can listen any of them in ur script function to change the behaviour, spinning, speed etc from any Constraint, Prismatic, Hinge, Servo/Motor etc.

So just add some lines to ur script:

First, under ur Hinges Instances add the Instance of the Servo Hinge:
(dont forget to rename ur spinning part to “SteerBeam” and the Servo Hinge to “SteerHinge”)
local steerServo = car.SteerBeam.SteerHinge

Find the MaxSpeed variable in your script and add these lines under it

-- Angle to steer
local angleSteer = 20

Find the carMove() function, inside that function put these lines:

-- if the property changed is Steer in the VehicleSeat then
	if property == "Steer" then
	-- Change the TargetAngle of the Servo
		steerServo.TargetAngle = angleSteer * seat.Steer
	end

That’s it. Ask if you have any problems, a lot of things could go wrong xD
Just be patient, you will notice that using Scripting and learning all the different Constraints you will be able to make more realistic and amazing cars :3

9 Likes

A car basically needs a hood. Where’s the hood?

Also try to practice to make better builds of cars, because this one is a good attempt

1 Like

If you want to try a more advanced suspension this is a good tutorial series:

Sorry for not being so specific: I know how to build a car, but not how to use Constraints and Scripts to make it work. Thanks though!

This is only the chassis of my car. I’m planning to build a blocky-ish body with Wedges and Parts on top (I don’t ever use Meshes except for tools)

1 Like

Thank you! It works great!

I modified it so that there were two SteerParts:
image

If you wanted to know, this is my car in Workspace:
image

I might add suspension or something at some point, but for now, it’s really good!

EDIT: Finished body!
image

5 Likes

Im so happy to see ur car finished!
I love that u experimented, and went for double Steer parts! Looks like u didnt have any troubles modifying the script.

Now that u learned the basics, feel free to experiment a lot. I checked a lot of tutorials on how making cars, but, I think that practice and experience on how to use all the Constraints (prismatic, springs, hinges, etc) and acceptable scripting skills its enough to make your own advanced cars and any kind of vehicle.

As Sir_Highness and I told you, its recomended now to learn how to implement suspension. Watch some tutorials, but always try it yourself too. I learned more from experiments than from tutorials.

Implement new ways to drive the vehicle, by not using VehicleSeat, instead, using custom Input, implement drifting FX, functions, locking, lights, sounds, progressive speed, move vehicles with BodyMovers too.
Thats why I dont think there is certain specific tutorial to learn how to make great vehicles… Its by testing, and creating custom ones that can be better than any tutorial. Become the master my friend!

Im so happy you got ur first scripted/constrained vehicle, now create a lot more with different specs. Dont forget to play with Density of the parts, Massless, etc, Custom Physics. :3

2 Likes

Sorry for bumping this, but I had a question:

Do I have to credit you for giving me this car script? I did modify it a little bit, but I wanted to make sure it was ok to use this in my game…

Thanks for your help!

Nah, No need for credit at all, its a very simple script and Im sure I watched something similar on a tutorial months ago. I had to learn from somewhere too xD

You are not having problems yet? Cause the default VehicleSeat has an important “glitch”, btw you built the suspension? How’s ur car going? if you need some help on making more advanced vehicles ask me if u like, I love to help, see ya :3

3 Likes

Yes, I built suspension using extra Parts as well as a SpringConstraint and a PrismaticConstraint. I built a standard Car Chassis with steering and suspension to build car bodies on top of. I also made a 4-wheel drive version for off-road vehicles.

I don’t know about VehicleSeats being glitchy… I’ve never had major problems with them.

I’ll add pictures later…

1 Like

The old hinge’s are still there, you need to weld it first with the surface in model, the the surface in property shows up and then you can set it to hinge

Hey there, sorry to bump. Clever code up here, I understood what you have done, but can you tell why does the car skid around at high speeds? If I change maxSpeed to 10 it works but then also it randomly turns like 10d or smth, is that something wrong with my code?
Havent implemented steering yet, heres the code:

local seat = script.Parent
local wheelBR = script.Parent.Parent.WheelBR
local wheelBL = script.Parent.Parent.WheelBL
local hingeBL = wheelBL.BL
local hingeBR = wheelBR.BR
local maxSpeed = 10
seat.Changed:Connect(function(input)
	if input == "Throttle" then
		hingeBL.AngularVelocity = seat.Throttle * maxSpeed
		hingeBR.AngularVelocity = seat.Throttle * maxSpeed
	end
end)

I had to multiply both motors by the positive value only as I rotated the hinge constraints earlier.
EDIT: nvm nvm nvm, I just made the front wheels drive too and its fixed now sorry for bumping :sweat_smile: