Calculateing how far a Vehicle will roll on an incline and or put in neutral?

I think I have the formulae for this but the BodyThrust (S) is to strong and makes the Vehicle shoot away into the distance what im trying to do is using bodymovers is calculating how fast and far a vehicle will roll when left on an incline or put in neutral here is the code im using to calculate this but I doubt it is right:

local RunService = game:GetService("RunService")

local Vehicle = workspace.Vehicle

RunService.Heartbeat:Connect(function(DeltaTime)
	local S = (Vehicle.Engine.Velocity.X + 0) / (DeltaTime * DeltaTime)
	Vehicle.Engine.BodyThrust.Force = Vector3.new(S, 0, 0)
end)

But it is way to strong if anyone could help me on this it would be much appreciated i got this formula from here:

But it does not seem right I do not want to use constraints

update

I have gotten closer but it still does not seem right im using body thrust and the formulae

local RunService = game:GetService("RunService")

local Vehicle = workspace.Vehicle

RunService.Heartbeat:Connect(function(DeltaTime)
	local S = (Vehicle.Engine.Velocity.X + 0) / (DeltaTime * DeltaTime)
	if Vehicle.Engine.Orientation.Z < -5 then
		Vehicle.Engine.BodyThrust.Force = Vector3.new(S / Vehicle.Engine.Mass, 0, 0)
	else
		Vehicle.Engine.BodyThrust.Force = Vector3.new(-S / Vehicle.Engine.Mass, 0, 0)
	end
end)
3 Likes

Sorry, but the major issue with this is the usage of the formula which calculates displacement while you are using it to input a force value, displacement != force (does not equal).

I believe a better and easier way to work with the Roblox physics engine to calculate the force needed to achieve a desired speed or distance is to use a PID controller to let the script adjust the amount of force for you to reach your goal whether it be moving your car a certain speed or automatically applying brakes when the car is stopped:

@ThanksRoBama made an excellent tutorial on this I highly suggest checking it out. Moreover, it can be used for other cooler things like spring suspension for a car in order to make it smooth as said from ScriptOn.

4 Likes

I have read the PiD control pt. 1 2 times now and I still do not understand how to use it or how it can be applied here.

3 Likes

PID does not seem to apply here because im not using vector force or trying to calculate how much force is needed to push

1 Like