So I have a motorcycle and I’m trying to balance the motorcycle but if I do that, you wouldn’t be able to turn.
Code:
local maxSteerAngle = 40
local accelerationSpeed = 0.25
local maxSpeed = 50
local maxTiltAngle = 20
local steer = 0
local throttle = 0
local runServiceConnection
local function Update(delta)
local steerGoal = -VehicleSeat.SteerFloat * maxSteerAngle
steer += (steerGoal - steer) * math.min(delta * VehicleSeat.TurnSpeed, 1)
attachF.Orientation = Vector3.new(attachF.Orientation.X, steer, attachF.Orientation.Z)
local tiltAngle = -steer / maxSteerAngle * maxTiltAngle
local tiltCFrame = CFrame.new()
tiltCFrame = tiltCFrame * CFrame.Angles(0, 0, math.rad(tiltAngle))
AlignOrientation.CFrame = tiltCFrame
local throttleGoal = VehicleSeat.ThrottleFloat
throttle += (throttleGoal - throttle) * math.min(delta * accelerationSpeed, 1)
local speed = maxSpeed * throttle
cylF.AngularVelocity = speed
cylR.AngularVelocity = speed
end
local function Start()
runServiceConnection = RunService.Heartbeat:Connect(Update)
end
local function Stop()
runServiceConnection:Disconnect()
end
Start()
Video: