Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I change the acceleration of this bodyposition/velocity (Vehicle)?

Asked by 6 years ago

Hello all! Back again with another question. I have created a vehicle using bodygyro, bodyposition,etc. I used the scripts from the jeep model on the race prebuilt map and modified them slightly to meet my needs. Basically I am creating a gearing system for my vehicles. Depending on what gear you are in, depends on how fast you are able to go. So far I have everything working, the vehicle drives, turns, and even can shift gears. However, my issue is that the vehicle accelerates very quickly, almost max speed instantly. My shifting script is based on speed, if you aren't going fast enough to shift gears, it won't let you, but being as the vehicle accelerates instantly, players can just spam the shift gear button and would defeat the purpose of shifting.

I'm basically trying to figure out how to make the velocity of the vehicle take time to reach its max. I know about MaxThrust, MaxTorque, and MaxForce, however with the Jeep script, editing any value also affects the turning. I was able to make the script slowly accelerate by editing the Lerp value, however that also made the turning wonky, causing it to go really fast while turning, or not turn at all. My question is what values do I need to be adjusting, need to add into the current script, to make it not accelerate to max speed instantly? I know about D and P aswell, but changing those values didn't affect anything. My assumption is because those values are used in relation to destination. Obviously a vehicle driving around has no set destination, therefor it can't damper it.

LocalCarScript

001--local camera = game.Workspace.CurrentCamera
002local player = game.Players.LocalPlayer
003local character = player.Character
004local humanoidRootPart = character.HumanoidRootPart
005local car = script:WaitForChild("Car").Value
006local stats = car:WaitForChild("Configurations")
007local Raycast = require(car.CarScript.RaycastModule)
008local object = car.Chassis -- your object here
009local gear = stats.Gear
010--local cameraType = Enum.CameraType.Follow
011 
012local movement = Vector2.new()
013local gamepadDeadzone = 0.14
014 
015car.DriveSeat.Changed:connect(function(property)
View all 199 lines...
0
How did you have the patience to write almost 200 lines of code what could be written in 50-75? User#19524 175 — 6y
0
This script came from a jeep inside one the pre-built maps you can choose from when starting a new game. Everything related to BodyGyros, BodyPosition, etc is new to me, so I was using this script as a bases to learn from, and to understand how it works. But i'm stumped on acceleration. WizyTheNinja 834 — 6y

Answer this question