Vehicle takes 2-3 seconds before it allows input. Propels forward during that time

Hi, I’m trying to get a vehicle to simulate physics properly when you get into a vehicle seat.

Currently, if I hop on the seat it will propel itself forward for 2-3 seconds, not allowing vehicle seat input to change it. Then it will finally give control to the player and stop propelling forward.

I’ve tried setting Network Ownership, but that doesn’t fix it.

local VehicleSeat = script.Parent
local JetskiModel = VehicleSeat.Parent
local BodyGyro = JetskiModel.PrimaryPart:WaitForChild("BodyGyro")
local Speed = VehicleSeat:GetAttribute("Speed")
local Range = 15

BodyGyro.CFrame = JetskiModel.PrimaryPart.CFrame
JetskiModel.PrimaryPart.BodyPosition.position = JetskiModel.PrimaryPart.Position

local function LERP(origin, target, percent)
	return origin + (target-origin)*percent
end

local function adjustThrottle()
	if VehicleSeat.Throttle == 1 or VehicleSeat.Throttle == -1 then
		VehicleSeat.Parent.Fire.ParticleEmitter.Enabled = true
	else
		VehicleSeat.Parent.Fire.ParticleEmitter.Enabled = false
	end
end

VehicleSeat:GetPropertyChangedSignal("Throttle"):Connect(function()
	adjustThrottle()
end)

VehicleSeat:GetPropertyChangedSignal("Steer"):Connect(function()
	adjustThrottle()
end)

VehicleSeat.Changed:Connect(function(prop)
	if prop == "Occupant" then
		local humanoid = VehicleSeat.Occupant
		if humanoid then
			local player = game:GetService("Players"):GetPlayerFromCharacter(humanoid.Parent)
			if player then
				VehicleSeat:SetNetworkOwner(player)
			end
		else
			VehicleSeat:SetNetworkOwnershipAuto()
		end
	end
end)

game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
	local CurrentSpeed = VehicleSeat.CFrame:VectorToObjectSpace(VehicleSeat.AssemblyLinearVelocity).Z*-1
	local Pitch = 0.15 + (CurrentSpeed / Speed)
	local Direction = VehicleSeat.CFrame.LookVector

	if VehicleSeat.Steer == 1 then
		BodyGyro.CFrame = BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0,-0.04*Pitch,0)
	elseif VehicleSeat.Steer == -1 then
		BodyGyro.CFrame = BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0,0.04*Pitch,0)
	end
	
	JetskiModel.PrimaryPart.BodyVelocity.Velocity = Direction * LERP(CurrentSpeed, Speed * math.clamp(VehicleSeat.Throttle, -0.3,1), 0.1)
end)

Here’s the Vehicle’s Hierarchy.
image

Try setting bodyvelocity’s velocity property to 0,0,0 when a player enters the seat
This might fix the problem

That does stop it from propelling forward when occupying the seat.

But it still isn’t very responsive to inputs for the first few seconds.

i guess to make the vehicle to be stationary for a few second might be anchoring the vehicle when player enters then wait few seconds tgen unanchor the vehicle

and im pretty sure you dont need to setnetwork ownership because the seat automatically makes it happen

also runservice heartbeat is less responsive use renderstepped

1 Like

That would require me to convert it into a LocalScript (or Module Script), as RenderStepped can only be run from the Client.

If I convert it to a Local Script or Module Script, I would have to run it from a different place than the Vehicle, as Client scripts are only ran from a select few places in the Explorer.

I would have to restructure the entire code to do this.

I did try an infinite wait loop instead of HeartbeatService, but the results are still the same, making me wonder if RenderStepped wouldn’t just be a dead end and waste of time restructuring my entire code to do it.

But you are right about the NetworkOwner. I thought that was the case, but put it in just to be sure.

but im thinking why not just remive the heartbeat thing??

That would look like this

But the problem still remains. For 2 to 3 seconds after gettting into the seat, I cannot control it’s turning, and its speed doesn’t work properly.

while true do
	wait()
	local CurrentSpeed = VehicleSeat.CFrame:VectorToObjectSpace(VehicleSeat.AssemblyLinearVelocity).Z*-1
	local Pitch = 0.15 + (CurrentSpeed / Speed)
	local Direction = VehicleSeat.CFrame.LookVector

	if VehicleSeat.Steer == 1 then
		BodyGyro.CFrame = BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0,-0.04*Pitch,0)
	elseif VehicleSeat.Steer == -1 then
		BodyGyro.CFrame = BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0,0.04*Pitch,0)
	end
	
	BodyVelocity.Velocity = Direction * LERP(CurrentSpeed, Speed * math.clamp(VehicleSeat.Throttle, -0.3,1), 0.1)
end

it seems youre checking the throttle update using getpropertychangesignal as ive heard this function is not reliable when making this kind of script i reccomend making it as a while wait loop

Actually that’s a little misleading. If you take a closer look, you’ll see GetPropertyChangedSignal is only used to enable and disable a particle emitter. I use to do it that way, but stopped using it. It still has the name AdjustThrottle for the function tho.

im quite surprised why you making everything complicated what you can do is

while wait(.1) do
   if Seat.Throttle ==1 then
      --move forward
   elseif  Seat.Throttle == -1 then
      --move backward
    elseif Seat.Throttle == 0 then
      --stop movement
     elseif Seat.Throttle == 1 then
       --go right
     elseif Seat.Throttle == -1 then
       --go left
     elseif Seat.Throttle == 0 then
       --stop steer
end

It’s to better simulate the physics.

My current system has proper slowing down and speeding up. Systems that use the setup you’ve offered tend to stop immediately when an input stops. For water based vehicles, or really vehicles in general, this is awkward.

It’s possible I can attempt to convert the system you’re suggesting with my more closely simulated system, but idk if that will fix it or work.

I am appreciating the brainstorming and help though. I did look into that system. Infact its what I started with before making adjustments to get better simulation.

also i have heard that body velocity just makes a vehicle go super fast try using body force
because body force makes the vehicle to go fast slowly just like a real vehicle

It doesn’t make vehicles (or objects) go super fast.
I think you’ve been misinformed.

It makes it go at a constant velocity, which might be what you mean. But the LERP function I have tells it to gradually speed up. LERP is just a fancy math that says get the % point from A to B. So 10% from 1 to 100 is 10, so it gets 10.

I use this to slowly reach a closer and closer point to the max speed over time.

Here, try out the Jetski in a baseplate with water. (Water is Optional atm.)

You’ll see what I mean.Jetski3.rbxm (42.0 KB)