-
What do you want to achieve? I am making a vehicle that has an attribute of max speed. Let’s say the value of it is 50.
-
What is the issue? When it sets the angular velocity to 50, for some reason the velocity of the vehicle is doubled.
-
What solutions have you tried so far? I couldn’t find solutions on the devhub since I am not sure how to word this correctly. I tried switching my vehicle from 8 wheel drive to 4 wheel drive like my previous one which works correctly, but that did not help. I tried changing the damping and the stiffness of the springs. I tried using a variable from inside the script instead of an attribute.
In this video, I set the max speed at 50, and then I got the velocity of 100. Then I set the max speed to 20, and get the velocity of 40.
local truck = script.Parent
local driverSeat = truck.DriverSeat
local platform = truck.Platform
driverSeat:GetPropertyChangedSignal("ThrottleFloat"):Connect(function()
local speed = driverSeat.ThrottleFloat * truck:GetAttribute("MaxSpeed")
for order, cyl in ipairs(platform:GetChildren()) do
if cyl.Name == "CylL" then
cyl.AngularVelocity = speed
elseif cyl.Name == "CylR" then
cyl.AngularVelocity = -speed
end
end
end)
driverSeat:GetPropertyChangedSignal("SteerFloat"):Connect(function()
local turn = driverSeat.SteerFloat * truck:GetAttribute("TurnAngle")
for order, att in ipairs(platform:GetChildren()) do
if att.Name == "AttLT" then
att.Orientation = Vector3.new(att.Orientation.X, -turn, att.Orientation.Z)
elseif att.Name == "AttRT" then
att.Orientation = Vector3.new(att.Orientation.X, -turn, att.Orientation.Z)
end
end
end)