Hi. I am making a chassis for a test, everything is working just fine, but the only problem I am getting is that the Chassis cannot move, but tires can rotate when pressing A/D. The constraint I am using to move the chassis is Cylindrical Constraint, and its AngularActuatorType is Motor, the AngularVelocity
is getting applied, but the chassis just don’t move, everything is unanchored. Help is appreciated
Here’s the code:
local stop = script.Stop
local seat = Car.VehicleSeat;
local attFL = Car.Platform.AttachmentFL
local attFR = Car.Platform.AttachmentFR
local maxSteeringAngle = 30
local cyFL = Car.Platform.CylindricalFL
local cyFR = Car.Platform.CylindricalFR
local cyRL = Car.Platform.CylindricalRL
local cyRR = Car.Platform.CylindricalRR
local steer = 0
local throttle = 0
local heartbeat
local function Update(dt)
local steerGoal = -seat.SteerFloat * maxSteeringAngle;
steer = steer + (steerGoal - steer) * math.min(dt * seat.TurnSpeed, 1)
attFL.Orientation = Vector3.new(0, steer, -90)
attFR.Orientation = Vector3.new(0, steer, -90)
local throttleGoal = seat.ThrottleFloat;
throttle = throttle + (throttleGoal - throttle) * math.min(dt * seat.TurnSpeed)
local torque = seat.Torque
local speed = seat.MaxSpeed * throttle
cyFL.MotorMaxTorque = torque
cyFR.MotorMaxTorque = torque
cyRL.MotorMaxTorque = torque
cyRR.MotorMaxTorque = torque
cyFL.AngularVelocity = speed
cyFR.AngularVelocity = -speed
cyRL.AngularVelocity = speed
cyRR.AngularVelocity = -speed
end
local function Start()
print("Start client")
heartbeat = game:GetService("RunService").Heartbeat:Connect(Update)
end
local function Stop()
print("Stop Client")
heartbeat:Disconnect()
script:Destroy()
end
Start()
if (stop.Value) then
Stop()
return
end
stop.Changed:Connect(function(shouldStop)
if (not shouldStop) then return end
Stop()
end)