How do I Accelerate my vehicle instantly to its maximum force using VectorForce?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to accelerate my vehicle instantly to the maximum force that I set on my VectorForce.

  2. What is the issue? Include screenshots / videos if possible!
    It takes time for my vehicle to accelerate to it’s maximum force

Also, the value of the force is 500 at X axis

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

-I tried to increase the value of the force and it instantly accelerated my vehicle, but it also increases my maximum force thus speeding up vehicle which is something that I don’t want to achieve. For recalling, I just want my vehicle to have an average speed which also instantly accelerates to that speed.

-I’m about to use BodyForces which I believe has the option regarding with my issue, but the Developer Page stated that the item is deprecated, which recommends me to use VectorForce instead.

-I also learned the other methods of creating vehicles through hinges and Vehicle seat, But as of now I’m focusing on using VectorForces because I find it applicable for what I am going for (another topic). Thus, I really hope it is possible to instantly accelerate the vehicle.

By the way, here is my code which fires whenever I press “W”

local ContextActionService = game:GetService("ContextActionService")
local Players = game:GetService("Players")

-- Variable for the player
local player = game.Players.LocalPlayer

-- Configuration variables
-- Sets the player's speed: The larger the negative number, the faster the ship will go.
local PLAYER_SPEED = 500
local FORWARD_KEY = Enum.KeyCode.W


-- Creates a force vector that uses player's speed
local forwardForceVector = Vector3.new(PLAYER_SPEED,0,0)

-- Movement function that is called when the player presses the move forward button
local function onMove(actionName, inputState)
	if inputState == Enum.UserInputState.Begin then
		-- If the player presses down the button, move forward
		player.Character.HumanoidRootPart.VectorForce.Force = forwardForceVector
	elseif inputState == Enum.UserInputState.End then
		-- If the player releases the button, stop moving 
		player.Character.HumanoidRootPart.VectorForce.Force = Vector3.new(0,0,0)
	end
end

-- Set up control bindings
ContextActionService:BindAction("Move", onMove, false, FORWARD_KEY)

As you may also notice, I am getting the Character’s humanoid root part, that’s because I changed the starter character to a vehicle, which makes the humanoid root part equivalent to the root part of my vehicle.

image
This is also the current structure of the vehicle as well.

In Accordance with the code, this would move the car forward whenever I press “W” (and it would not stop).

This is not the whole design of the car though but I just made it simple for the post.

Thank you so much!
I’m also new to Roblox studio as well, started like 2 weeks ago.

So it seems like you want faster acceleration but maintain the maximum speed?

One option is body velocity however you cannot control is as much vs the second method:

For VectorForces I would recommend adding a drag force, this will prevent the vehicle from constantly accelerating. The plus side is that the drag force is very modifiable and the equation can be adjusted currently, it’s set the velocity squared based on physics.

1 Like

yo thank you so much, at first I thought VectorForce has limits, but when I used the print(speed) from the drag force code I just realized that my VectorForce continues to increase. To sum up, I just implemented the drag force formula from my code and to be honest I haven’t completely understand it lol (especially for the unit of speed that is printed on the output), but anyhow, I managed to set a limit and at the same time increase my acceleration time. Thank you so much

2 Likes