I have an open-source car chassis that uses crazyman32’s rig, but it also includes a gear system and ackermann steering, and stuff.
WOW That answered all my questions tysm!
How did you get the car to steer so smoothly? Mine turns like a flat block of cheese, even after trying to get it looking like yours with like 30 minutes of trying different things
I’m having trouble with using spheres instead of cylinders. I can run the script to move and resize the cylinders over the wheels but when I run it on the sphere it shrinks too much and doesn’t move. Including a picture and the code I typed into the command bar. I’m not sure how to make spheres work? Could someone please help me figure this out?
local first = selection[1]
local last = selection[2]
first.Size = last.Size
first.CFrame = last.CFrame
This is because spheres can only have the same size on each axis. Try making the sphere’s size slightly larger than the size of last
.
When I changed the sphere’s size to 10, 10, 10 the ran the command it moved it this time but it still shrunk it too much.
Try making it bigger…
Ok so I used the command to get it into the correct position then manually resized it to 2.6, 2.6, 2.6
Thank you! Really appreciate you taking the time to help
Np. Just keep in mind that since it’s a sphere, it will be sticking out of the sides of the car, and there is really no method (That I know of) to fix this.
I just wanted to try it out both ways to see what worked better on my game. Thanks
You need to play with the CylindricalConstraint settings and make the turn speed something like 2-5 to make the steering smooth. I also recommend changing with the cars mass.
Trail and after trial until you reach what you want!
I tried messing around with the different CylindricalConstraint settings for a while, which ones do you mean exactly? and do you increase them/decrease them?
You are a godsend my friend. This is amazing, thank you so much. You were so detailed in everything and the way it worked. I can now say that I can rig and script a car on my own thanks to this. Thank you so much again. Loved it.
This post is when i learnt that i could use a cylindrical constraint instead of using another part to join the spring and the prismatic constraint to the wheel with a hinge constraint. This method is so much better as the weels dont seem to glitch.
Hello so i have a problem in the third part, my code dosent work i tried to rewrite it a lot of times but still wrong, can someone help me?
local car = script.Parent
local seat = car.Body.VehicleSeat
local body = car.Body.Body
local physicsService = game:GetService("PhysicsService")
local defaultCollisionGroup = "Default"
local characterCollisionGroup = "Character"
local cooldown = 0
local occupiedPlayer
local function Cooldown(durantion)
local cooldownTag = tick()
cooldown = cooldownTag
delay(durantion, function()
if (cooldown == cooldownTag) then
cooldown = 0
end
end)
end
local function SetCharacterCollide(character, shouldCollide)
local group = (shouldCollide and defaultCollisionGroup or characterCollisionGroup)
for _,part in ipairs(character:GetDescendants()) do
if (part:IsA("BasePart")) then
part.Massless = not shouldCollide
physicsService:SetPartCollisionGroup(part, group)
end
end
end
local function BodyTouched(part)
if (seat.Occupant or cooldown ~= 0) then return end
local character = part.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if (not player) then return end
local humanoid = character:FindFirstChildOfClass("humanoid")
if (not humanoid) then return end
seat:Sit(humanoid)
occupiedPlayer = player
SetCharacterCollide(character, false)
car.PrimaryPart:SetNetworkOwner(player)
Cooldown(1)
end
local function OccupantChanged()
if (seat.Occupant) then return end
if (occupiedPlayer.Character) then
SetCharacterCollide(occupiedPlayer.Character, true)
end
car.PrimaryPart:SetNetworkOwner(player)
occupiedPlayer = nil
end
body.Touched:Connect(BodyTouched)
seat:GetPropertyChangedSignal("Occupant"):Connect(OccupantChanged)
Just a question,
Will it lag if a bunch of vehicles are driving around?
Great Tutorial! Really well explained and detailed, it would be awesome if there was a continuation, where you show us how to add more stuff to the car gauges, turning signals, etc.
I don’t think so, i might be wrong. The script transfers network ownership to the local player but you can still lag when you have a LOT of them, depends on your pc specs.
Your missing a lot of code from the tutorial idk if you followed the whole tutorial but this was the final code:
local car = script.Parent
local seat = car.Body.VehicleSeat
local body = car.Body.Body
local physicsService = game:GetService("PhysicsService")
local DefaultCollisionGroup = "Default"
local CharacterCollisionGroup = "Character"
local cooldown = 0
local OccupiedPlayer
local OccupiedClientScript
local carClientScript = script.CarClient
local function Cooldown(duration)
local cooldownTag = tick()
cooldown = cooldownTag
delay(duration,function()
if (cooldown == cooldownTag) then
cooldown = 0
end
end)
end
local function SetCharacterCollide(character,ShouldCollide)
local group = (ShouldCollide and DefaultCollisionGroup or CharacterCollisionGroup)
for _,part in ipairs(character:GetDescendants()) do
if (part:IsA("BasePart")) then
part.Massless = not ShouldCollide
physicsService:SetPartCollisionGroup(part, group)
end
end
end
local function BodyTouched(part)
if (seat.Occupant or cooldown ~= 0) then return end
local character = part.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if (not player) then return end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if (not humanoid) then return end
seat:Sit(humanoid)
OccupiedPlayer = player
SetCharacterCollide(character,false)
car.PrimaryPart:CanSetNetworkOwnership(player)
OccupiedClientScript = carClientScript:Clone()
OccupiedClientScript.Car.Value = car
OccupiedClientScript.Parent = player.Backpack
Cooldown(2)
end
local function OccupantChanged()
if (seat.Occupant) then return end
if (OccupiedPlayer.Character) then
SetCharacterCollide(OccupiedPlayer.Character,true)
end
if (OccupiedClientScript.Parent) then
OccupiedClientScript.Stop.Value = true
local client = OccupiedClientScript
delay(3, function()
client:Destroy()
end)
end
car.PrimaryPart:SetNetworkOwnershipAuto()
OccupiedPlayer = nil
OccupiedClientScript = nil
Cooldown(3)
end
body.Touched:Connect(BodyTouched)
seat:GetPropertyChangedSignal("Occupant"):Connect(OccupantChanged)