Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local QuadBike = script.Parent
- local vehicleSeat = QuadBike.VehicleSeat
- local rear_axle = QuadBike.rear_axle
- local front_axle = QuadBike.front_axle
- local MotorLB = rear_axle.wheel_axle.CylindricalConstraint_l
- local MotorRB = rear_axle.wheel_axle.CylindricalConstraint_r
- local MotorLF = front_axle.wheel_axle.CylindricalConstraint_l
- local MotorRF = front_axle.wheel_axle.CylindricalConstraint_r
- local MaxSpeed = vehicleSeat.MaxSpeed
- local currentVelocity = vehicleSeat.AssemblyLinearVelocity
- local torqueMax = 1000000
- local RotateVel = 50
- MotorLB.MotorMaxTorque = torqueMax
- MotorRB.MotorMaxTorque = torqueMax
- MotorLF.MotorMaxTorque = torqueMax
- MotorRF.MotorMaxTorque = torqueMax
- local function setMotorVelocity(vel)
- MotorLF.AngularVelocity = vel
- MotorLB.AngularVelocity = vel
- -- Моторы с правой стороны должны вращать
- -- колёса по часовой стрелки, а слева - против
- MotorRF.AngularVelocity = -vel
- MotorRB.AngularVelocity = -vel
- end
- while true do
- -- Проверка ввода при помощи vehicleSeat
- local steerFloat = vehicleSeat.SteerFloat
- -- Вперёд и назад, значение от -1 до 1
- local throttle = vehicleSeat.ThrottleFloat
- -- Влево и вправо, значение от -1 до 1
- if steerFloat == 0 then
- if throttle ~= 0 then
- setMotorVelocity(throttle * RotateVel)
- end
- if throttle == 0 then
- setMotorVelocity(0)
- end
- end
- if steerFloat < 0 then
- MotorLB.AngularVelocity = -0.7*RotateVel
- MotorRB.AngularVelocity = -RotateVel
- MotorLF.AngularVelocity = -0.7*RotateVel
- MotorRF.AngularVelocity = -RotateVel
- wait()
- end
- if steerFloat > 0 then
- MotorLB.AngularVelocity = RotateVel
- MotorRB.AngularVelocity = 0.7*RotateVel
- MotorLF.AngularVelocity = RotateVel
- MotorRF.AngularVelocity = 0.7*RotateVel
- wait()
- end
- if vehicleSeat.Orientation.Z > 90 or vehicleSeat.Orientation.Z < -90 then
- wait(1)
- vehicleSeat.CFrame = CFrame.new(vehicleSeat.Position) *
- CFrame.Angles(0, vehicleSeat.Orientation.Y, 0)
- end
- wait()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement